sql = "insert into usermain (userid,userpass,username,usermail) values('" + TextBox1.Text + "','" + TextBox2.Text + "','" + TextBox4.Text + "','" + TextBox5.Text + "')"cmd = new SqlCommand(sql,conn)cmd.ExecuteNonQuery()注意检查一下,你漏写了什么东西。

解决方案 »

  1.   

    楼上的说的很对!
    cmd = new SqlCommand(sql,conn)  !!!
    我奇怪的是 你的代码前几天还可以用?????
      

  2.   

    to:楼上2位兄弟
    Dim cmd As New SqlClient.SqlCommand(sql, conn)
    cmd = new SqlCommand(sql,conn)
    这条语句有什么区别?难道....
      

  3.   

    vb 和 c# 不同罢了。
      

  4.   

    在执行sql = "insert into usermain (userid,userpass,username,usermail) values('" + TextBox1.Text + "','" + TextBox2.Text + "','" + TextBox4.Text + "','" + TextBox5.Text + "')"时,你要再新建一个SqlCommand实例