代码:与添加查询参数的问题
com.CommandText = "select username, pass from Employees where lastName like '@Last' and firstName like '@First'";
com.Parameters.AddWithValue("@Last", lastName); // lastName is a method argument
SqlParameter param = new SqlParameter();
param.ParameterName = "@First";
param.Value = firstName;
com.Parameters.Add(param);
不管我做什么,参数没有插入。是什么赋予了?
会发生什么,你得到一个例外?如果是这样,什么是例外? – CodingGorilla 2011-03-10 19:11:45
正如我所说的,参数没有插入;该字符串具有文字@Last和@First。 – 2011-03-10 19:17:04
您是否使用Sql profiler查看发送到服务器的命令?你如何确定“该字符串的文字是@Last和@First”?这是什么意思? – 2011-03-10 20:46:37