webressurs
asked on
SQL parameters in ASP.NET, best practise?
Hello,
It is different ways of adding SQL parameters in ASP.NET. I need some info about what I shoul use when adding these parameters. Under is 2 examples that both works fine. The first examples is the fastes to code, but is it as good as the second example? I have also heard aboute using "Parameters.AddWithValue", when is this ment to be used?
--------------------------
Example 1
--------------------------
Cmd.Parameters.Add("@Email ", SqlDbType.NVarChar,255).Va lue = email;
--------------------------
Example 2
--------------------------
SqlParameter Email = new SqlParameter("@Email", SqlDbType.NVarChar,255);
Email.Value = email;
Cmd.Parameters.Add(Email);
It is different ways of adding SQL parameters in ASP.NET. I need some info about what I shoul use when adding these parameters. Under is 2 examples that both works fine. The first examples is the fastes to code, but is it as good as the second example? I have also heard aboute using "Parameters.AddWithValue",
--------------------------
Example 1
--------------------------
Cmd.Parameters.Add("@Email
--------------------------
Example 2
--------------------------
SqlParameter Email = new SqlParameter("@Email", SqlDbType.NVarChar,255);
Email.Value = email;
Cmd.Parameters.Add(Email);
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
http://www.aspfree.com/c/a/ASP.NET/Query-Parameters-and-Information-Handling-with-Databases/