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
我不知道这里的问题是什么。我猜这是组合框,组合框中的选定值应该添加到数据库中。该组合框的正确值是什么?有人能帮助我吗?
答案 0 :(得分:1)
它告诉您指定要插入(8)的列数不同于要插入的值的数量(6)。这是因为你已将2个值连接到2个字段中我相信,只需计算它们就可以了解我的意思。