我得到了异常,列不能为空,没有保存到我的数据库。
Private Sub save_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles save.Click
con.close()
con.open()
cmd = New Odbc.OdbcCommand("INSERT INTO db.table(firstname,lastname) VALUES(@f1,@f2)", con)
cmd.Parameters.AddWithValue("@f1", textboxfirstname.Text)
cmd.Parameters.AddWithValue("@f2", textboxlastname.Text)
cmd.ExecuteNonQuery()
End Sub
但如果我将使用此代码
Private Sub save_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles save.Click
con.close()
con.open()
cmd = New Odbc.OdbcCommand("INSERT INTO db.table(firstname) VALUES('" & textboxfirstname.Text & "')", con)
cmd.ExecuteNonQuery()
End Sub