我想批量修改一组数据 然后这个修改的值是变量从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 这样写对吗?
解决方案 »
- 急急急!!关于Jquery Easy UI Datagrid全选的问题
- WebHttpRequest获取网页内容,如何保存Cookie?(js脚本生成的cookie)
- 求 NavigationService.Navigate 的完事示例用法。
- 关于在多线程中使用Lock
- Microsoft.JScript.Eval.JScriptEvaluate 这个函数支持函数吗?
- C#用ReadProcessMemory读出的字符怎么才能正常显示啊,读出的byte[]不能转换回中文字符的.
- 怎么在菜单项前加图标?!
- DataGrid的问题,谢谢指教!
- C#主程序里调用DLL文件,调用的DLL怎样使用主程序里的函数,及变量?
- (winform)如何取消DataGrid的编辑模式?
- 怎么取消列表框的选中状态?
- C#数据类型怎么转换?
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();