sql SqlParameter 怎么用的
1个回答
2013-11-18
展开全部
string sqlcom = "select * from test where id =@id and name = @name";
SqlDataAdapter sqldataadapter = new SqlDataAdapter();
sqldataadapter.SelectCommand = sqlCmd;
SqlParameter para2 = new SqlParameter("id", SqlDbType.VarChar, 10);
para2.Value = "1";
SqlParameter para3 = new SqlParameter("name", "1");
SqlParameter[] para = { para2, para3 };
foreach (SqlParameter te in para)
{
sqldataadapter.SelectCommand.Parameters.Add(te);
}
SqlDataAdapter sqldataadapter = new SqlDataAdapter();
sqldataadapter.SelectCommand = sqlCmd;
SqlParameter para2 = new SqlParameter("id", SqlDbType.VarChar, 10);
para2.Value = "1";
SqlParameter para3 = new SqlParameter("name", "1");
SqlParameter[] para = { para2, para3 };
foreach (SqlParameter te in para)
{
sqldataadapter.SelectCommand.Parameters.Add(te);
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询