Error: Anzahl der Abfragewerte und Zielfelder sind nicht gleich
Public Class RoomInfo
Dim ValTx As String
Dim ValNr As Integer
Private Sub cboRoomType_DropDown(sender As System.Object, e As System.EventArgs) Handles cboRoomType.DropDown
cboRoomType.Items.Clear()
qry = "select RoomType from tblRoomType"
cmd = New OleDb.OleDbCommand(qry, con)
dr = cmd.ExecuteReader
While dr.Read
cboRoomType.Items.Add(dr("RoomType"))
End While
End Sub
Private Sub cboRoomType_SelectValueChanged(sender As Object, e As System.EventArgs) Handles cboRoomType.SelectedValueChanged
ValTx = cboRoomType.Text
qry = "select RoomType from tblRoomType where RoomType = '" & ValTx & "'"
cmd = New OleDb.OleDbCommand(qry, con)
dr = cmd.ExecuteReader
If dr.Read Then
ValTx = dr("RoomType")
End If
End Sub
Private Sub btnNext_Click(sender As System.Object, e As System.EventArgs) Handles btnNext.Click
qry = "Insert into tblCheckIn (Guest_ID, GRoomType, GRoomNo, GRoomID, GRoomAmount, CheckInDate, Days, ChecOutDate) values ('" &
txtGuestID.Text & "','" &
ValTx &
txtRoomNo.Text & "','" &
txtRoomId.Text & "','" &
txtRAmount.Text & "','" &
dtpCheckIn.Value &
txtDays.Text & "','" &
dtpCheckOut.Value & "')"
cmd = New OleDb.OleDbCommand(qry, con)
dr = cmd.ExecuteReader()
MsgBox("Successfully added in the database")
End Sub
Ich weiß nicht, was das Problem hier ist. Ich denke, es ist das Kombinationsfeld, der ausgewählte Wert im Kombinationsfeld sollte in der Datenbank hinzugefügt werden. Was ist der richtige Wert für diese Combobox? Kann mir jemand helfen