数据库,有源代码.请高手指教!! 你试一下,在表名上加[]INSERT INTO [Friends] 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 加了[]也不行,我怀疑这些语句有很大问题...(Name,Sex,Age,Telephome,Address_Home,Address_Inc,Note)VALUES(";strInsert+=this.textName .Text + ",'";strInsert+=this.textSex.Text + "','";strInsert+=this.textAge .Text + "',";strInsert+=this.textTelephome.Text +"',";strInsert+=this.textHomeAddress .Text +"'.";strInsert+=this.textIncAddress .Text +"',";strInsert+=this.textNote .TabIndex +")"; 你中间少了几个单引号!string strInsert="INSERT INTO Friends(Name,Sex,Age,Telephome,Address_Home,Address_Inc,Note)VALUES('";strInsert+=this.textName.Text + "','";strInsert+=this.textSex.Text + "','";strInsert+=this.textAge.Text + "','";strInsert+=this.textTelephome.Text +"','";strInsert+=this.textHomeAddress .Text +"','";strInsert+=this.textIncAddress .Text +"','";strInsert+=this.textNote .TabIndex +"')";上面已经把'添加完成,另外,有个地方你把,输成了.,所以会出错。 你把最后生成的sql语句弄出来,在access上查询看看有没有错误就知道了 这种问题最好的办法就象cforce说的那样把那个sql字符串打印出来看比较清楚! 提个小醒,这样子hard codeing的sql语句很容易受到Cross Site Scripting的攻击,例如你那个textIncAddress的值我填一个这样的字符串:abcd','1') delete friends --这样你的表就完啦 字符串反转 让“F_222”变成“F_223”最快的方法 服务端调试问题 字母排序 Uri 相对路径转换的问题 水晶报表怎么登录数据库啊? DataRead.GetDatetime问题 请教:如何从.aspx文件链接到.asp文件 C#能写嵌套方法吗? DrawString(string s, Font font, Brush brush, float x, float y); 坐标单位是像素吗 用基于C#的ASP.NET开发B/S模式的OA系统如何?? C#中如何实现动态加载装配件?
strInsert+=this.textName .Text + ",'";
strInsert+=this.textSex.Text + "','";
strInsert+=this.textAge .Text + "',";
strInsert+=this.textTelephome.Text +"',";
strInsert+=this.textHomeAddress .Text +"'.";
strInsert+=this.textIncAddress .Text +"',";
strInsert+=this.textNote .TabIndex +")";
string strInsert="INSERT INTO Friends(Name,Sex,Age,Telephome,Address_Home,Address_Inc,Note)VALUES('";
strInsert+=this.textName.Text + "','";
strInsert+=this.textSex.Text + "','";
strInsert+=this.textAge.Text + "','";
strInsert+=this.textTelephome.Text +"','";
strInsert+=this.textHomeAddress .Text +"','";
strInsert+=this.textIncAddress .Text +"','";
strInsert+=this.textNote .TabIndex +"')";
上面已经把'添加完成,另外,有个地方你把,输成了.,所以会出错。
把那个sql字符串打印出来看比较清楚!
abcd','1') delete friends --
这样你的表就完啦