Error in issuing Parameterized Command
hi i am encountered such error like this in the below code
strSql="select * from member where username=N'@username and password=N'@password";//
SqlDataAdapter objCommand=new SqlDataAdapter(strSql,objConnection);
objCommand.SelectCommand.Parameters.Add(new SqlParameter("@username",SqlDbType.NVarChar,50));//.Value=username.Text;
objCommand.SelectCommand.Parameters["@username"].Value="ali";//username.Text;
objCommand.SelectCommand.Parameters.Add(new SqlParameter("@password",SqlDbType.NVarChar,50));
objCommand.SelectCommand.Parameters["@password"].Value="12";//password.Text;
DataSet ds=new DataSet();
objCommand.Fill(ds,"member_info");
the error message is such thisSystem.Data.SqlClient.SqlException: Line 1: Incorrect syntax near '@password'. at System.Data.SqlClient.SqlCommand.ExecuteReader(Com mandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream) at System.Data.SqlClient.SqlCommand.ExecuteReader(Com mandBehavior behavior) at System.Data.SqlClient.SqlCommand.System.Data.IDbCo mmand.ExecuteReader(CommandBehavior behavior) at System.Data.Common.DbDataAdapter.FillFromCommand(O bject data, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior) at System.Data.Common.DbDataAdapter.Fill(DataSet dataSet, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior) at System.Data.Common.DbDataAdapter.Fill(DataSet dataSet, String srcTable) .....
any one help me to do it
regards:)
__________________
YoOrD .
Beauty is not on the face
Beauty is on the heart
~~<<Ghibran Khalil>>~~
|