我想批量修改一组数据 然后这个修改的值是变量从textbox.text取得的,string a=textbox.text;
sqlcommand aacommand=thisconnection.createcommamd();
aacommand.commandText="update info set"+ "name="+ a + " where supplierid ="+id;
int num=aacommand.executenonquery();
其中 aacommand.commandtext 这样写对吗?
sqlcommand aacommand=thisconnection.createcommamd();
aacommand.commandText="update info set"+ "name="+ a + " where supplierid ="+id;
int num=aacommand.executenonquery();
其中 aacommand.commandtext 这样写对吗?
string sql="update info set"+ "name="+ a + " where supplierid ="+id;
SqlCommand cmd = new SqlCommand(sql, connection);
只要类型对,这样写就可以的
string sql="update info set name="+ a.tostring()+ " where supplierid ="+id.toint32();
其中 a和 id最好用参数@name ,@id 不如很容易被sql注入的!http://www.mybuffet.cn
string a=textbox.text;
sqlcommand aacommand=thisconnection.createcommamd();
aacommand.commandText="update info set name='"+ a.Replace("'","''") + "' where supplierid = "+id;
int num=aacommand.executenonquery();