Initialize the property of a SqlParameter object in C#

In this example, two ParameterName properties are assigned with two dynamic parameters, “ @Param1 ” and “ @Param2 ” , respectively. Both Param1 and Param2 are nominal names of the dynamic parameters and an @ symbol is prefi xed before each parameter since this is the requirement of the SQL Server database when a dynamic parameter is utilized in an SQL statement.

SqlParameter paramUserName = new SqlParameter();
SqlParameter paramPassWord = new SqlParameter();
paramUserName.ParameterName = "@Param1";
paramUserName.Value = txtUserName.Text;
paramPassWord.ParameterName = "@Param2";
paramPassWord.Value = txtPassWord.Text;

Enjoyed this post? Share it!


Leave a comment

Your email address will not be published.