等价于拼接字符串的传参的SQL赋值方法


string sqlStr = "insert into people values(@username,@peoplecode,@dpt)";
SqlCommand cmd = new SqlCommand(sqlStr,conn);
cmd.Parameters.Add("@username", SqlDbType.NVarChar).Value = username;
cmd.Parameters.Add("@dpt", SqlDbType.Int).Value = dpt;
cmd.Parameters.Add("@peoplecode", SqlDbType.NVarChar).Value = peopleCode;
conn.Open();

 

黑色头发:http://heisetoufa.iteye.com/

你可能感兴趣的:(sql)