向我的OleDbCommand
添加参数时出现错误。错误告诉我@Gender
没有默认值。
SQL = "INSERT INTO MEMBER ( [RFID], [ID], [FULLNAME], [POSITION], [GENDER]," & _
" [DATEENCODED] )VALUES ( @RFID, @ID, @FULLNAME, @POSITION, @GENDER, @DATEENCODED)"
Dim cmd As New OleDb.OleDbCommand(SQL, conn)
cmd.Parameters.Add(New OleDb.OleDbParameter("@RFID", Form3.txtrfid.Text))
cmd.Parameters.Add(New OleDb.OleDbParameter("@ID", Form3.txtid.Text))
cmd.Parameters.Add(New OleDb.OleDbParameter("@FULLNAME", a))
cmd.Parameters.Add(New OleDb.OleDbParameter("@POSITION", Form3.txtpost.Text))
cmd.Parameters.Add(New OleDb.OleDbParameter("@GENDER", Form3.cbogen.SelectedItem))
cmd.Parameters.Add(New OleDb.OleDbParameter("@DATEENCODED", b))
答案 0 :(得分:0)
在设计时,将组合框的DropDownStyle属性设置为DropDownList 使用数据源,而不是在设计时将项目添加到集合中,或者在运行时将Items.Add或Items.AddRange添加到集合中。 / p>
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
Dim G() As String = {"Male", "Female", "Other"}
ComboBox1.DataSource = G
MessageBox.Show(ComboBox1.SelectedItem.ToString)
End Sub