cmd.CommandText = "Insert into Itemlist(Item Code,Supplier Code,Item English Name,Item Chinese Name,NPP,Major Material,NSP,Size,GM,Color)";
cmd.CommandText += " Values (" + txtItemCode.Text + ",'";
cmd.CommandText += txtSupplier.Text + "','";
cmd.CommandText += txtNameE.Text + "','";
cmd.CommandText += txtNameC.Text + "',";
cmd.CommandText += txtNPP.Text + ",'";
cmd.CommandText += txtMaterial.Text + "',";
cmd.CommandText += txtNSP.Text + ",'";
cmd.CommandText += txtSize.Text + "',";
cmd.CommandText += txtGM.Text + ",'";
cmd.CommandText += txtColor.Text + "')";其中Item Code,NPP,NSP,GM为数字型的
cmd.CommandText += " Values (" + txtItemCode.Text + ",'";
cmd.CommandText += txtSupplier.Text + "','";
cmd.CommandText += txtNameE.Text + "','";
cmd.CommandText += txtNameC.Text + "',";
cmd.CommandText += txtNPP.Text + ",'";
cmd.CommandText += txtMaterial.Text + "',";
cmd.CommandText += txtNSP.Text + ",'";
cmd.CommandText += txtSize.Text + "',";
cmd.CommandText += txtGM.Text + ",'";
cmd.CommandText += txtColor.Text + "')";其中Item Code,NPP,NSP,GM为数字型的
解决方案 »
- 如何将excel表中的数据导入到数据库中
- 在用matlab与c#混合编程时出现如下的错误,大家给点意见吧,谢谢了!着急!
- 未能找到元数据文件“ .exe”
- sql2005的问题,大家帮忙下
- 请问 vb中的 AddHandler changePathBtn.Command,AddressOf ChangePath; 写成c#的怎么写啊!
- 一小段C程序,求看得懂的给讲解一下。
- c#如何让一个listbox中的某一数据通过一个BUTTON按钮转移到另一个listbox中去
- 关于接收邮件的程序中对邮件的html的解析问题
- 这么为WEB服务创建数据库
- 备份数据库
- 新线程中为什么不能访问外面的控件?
- 数据库服务器是由公网服务器端口映射得到的,我怎么操作数据库呢?
cmd.CommandText = "Insert into Itemlist([Item Code],[Supplier Code],[Item English Name],[Item Chinese Name],NPP,Major Material,NSP,Size,GM,Color)";
cmd.CommandText += " Values (" + txtItemCode.Text + ",'";
cmd.CommandText += txtSupplier.Text + "','";
cmd.CommandText += txtNameE.Text + "','";
cmd.CommandText += txtNameC.Text + "',";
cmd.CommandText += txtNPP.Text + ",'";
cmd.CommandText += txtMaterial.Text + "',";
cmd.CommandText += txtNSP.Text + ",'";
cmd.CommandText += txtSize.Text + "',";
cmd.CommandText += txtGM.Text + ",'";
cmd.CommandText += txtColor.Text + "')";
对于数值的插入,不需要另外处理。
int a;
a = int.Parse(textbox1.Text);
那么上面的代码可以改为:
cmd.CommandText = "Insert into Itemlist(Item Code,Supplier Code,Item English Name,Item Chinese Name,NPP,Major Material,NSP,Size,GM,Color)";
cmd.CommandText += " Values (" + int.Parse( txtItemCode.Text) + ",'";
其他的类似,看看行不行。另外写SQL语句是要注意是否书写正确。