本文介绍了错误:查询值和目标字段的数量不同的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
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
我不知道这里是什么问题.我想这是组合框,组合框中选择的值应添加到数据库中.该组合框的正确正确值是多少?有人可以帮我吗?
I dont know what the problem is here. I guess it's the combobox, the selected value in combo box should be added in database. What is the right correct value for that combobox? Can someone help me?
推荐答案
它告诉您指定的要插入(8)的列数与要插入的值(6)的数不同.这是因为您已经将其中的两个值串联到2个字段中,只要对它们进行计数,您就会明白我的意思.
It is telling you that you have specified a different number of column to insert into (8) than the number of values to insert (6). This is because you have concatenated 2 of the values into 2 field I believe, just count them and you will see what I mean.
这篇关于错误:查询值和目标字段的数量不同的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!