数据库插入语句问题,求指导

.Net技术 码拜 9年前 (2016-03-05) 783次浏览
数据库插入语句问题,求指导
把textbox的内容插入数据库,老是显示失败,求指导c#代码如下
OleDbConnection odc = db.GetCon();//数据库连接
StringBuilder sb = new StringBuilder();
sb.Append(textBox2.Text);
string a = “q”;
string strsql = “insert into my(name,index) values(“” + a + “”,”” + sb + “”)”;
OleDbCommand comm = new OleDbCommand(strsql, odc);
comm.ExecuteNonQuery();
odc.Close();
解决方案

20

string strsql = “insert into my([name],[index]) values(“” + a + “”,”” + sb.ToString() + “”)”;
字段是关键字吧,这样试下

CodeBye 版权所有丨如未注明 , 均为原创丨本网站采用BY-NC-SA协议进行授权 , 转载请注明数据库插入语句问题,求指导
喜欢 (0)
[1034331897@qq.com]
分享 (0)