明显错啦
看看你的那个strInsert
在第二行的地方少了一个单引号如果你的TEXTBOX里面是数字或者日期什么的,是要经过转换的用Convert或是(type)都可以的

解决方案 »

  1.   

    关于数据库方面的错误,我的经验是:
    捕获异常,使用Debug.WriteLine或者MessageBox.Show来显示异常,然后对应处理。
    一般来说如果提示sql语句错误,你就应该用上面的方法把sql也打印出来,当然是赋值以后的sql语句。
    这样很方便就检查出来错误了。
    另外sql server插入事件日期的时候是当作字符串处理的,也就是需要' ' 筐起来。
    至于日期的转换你可以查msdn,有很详细的例子。
      

  2.   

    你可以把SQL语句提出来到数据库中看看
    或许有帮助
      

  3.   

    strInsert 你不觉得多于吗!
      

  4.   

    VALUES ('this.textBox1.Text ','this.textBox2.Text ','this.comboBox1.Text ','this.textBox3.Text ','this.textBox4.Text ')
    应该可以了吧
      

  5.   

    这样子写:
    string strInsert = " INSERT INTO person ( id , xm , xb , nl , zip ) VALUES ( '" ;
    strInsert += this.textBox1.Text + "','" ;
    strInsert += this.textBox2.Text + "', '" ;
    strInsert += this.comboBox1.Text + "', " ;
    strInsert += this.textBox3.Text + "', '" ;
    strInsert += this.textBox4.Text + "')" ;
      

  6.   

    我已经将相关的地方修改为: string strInsert = " INSERT INTO person ( id , xm , xb , nl , zip ) VALUES ( " ;
                        strInsert += this.textBox1.Text + ",'" ;     strInsert += this.textBox2.Text + "', '" ;     strInsert += this.comboBox1.Text + "', " ;     strInsert += this.textBox3.Text + ", '" ;     strInsert += this.textBox4.Text + "')" ;
    不过还是有错误,错误原因为:保存数据记录发生System.NullReferenceException;未将对象引用设置到对象的实例 。
    在数据库中我把id ,nl 设为int类型 ,其它的三个设为text类型,我想是不是要把TextBox1(id)和TextBox3(nl)中的内容要转化为int类型 ,我想到用转化语System.Convert.ToInt32(),但是又带来其他的问题,要想实现该数据库插入功能,该怎么用这个转化语句?(最好写出该部分的代码出来)或者是其他方面的原因,请高手指教!