Dear Friends

I worked with VB.NET V 2005
In my project i have using so many sql statements (insert, update..) those working properly
In newly i created form i have coded sql insert statement
so when i execute it its getting error "Number of query values and destination fields are not the same"
so friend i cant recognize what is this error
this is my error code

Com.CommandText = "Insert into tblReservation Values(?,?,?,?,?,?,?,?)"
                With Com.Parameters
                    .Add("@CusID", OleDbType.VarChar).Value = CusNo
                    .Add("@ResType", OleDbType.VarChar).Value = ResTyp
                    .Add("@RTType", OleDbType.VarChar).Value = RTbTyp
                    .Add("@RTNo", OleDbType.Integer).Value = RoTbNo
                    .Add("@ResDate", OleDbType.Date).Value = txtDate.Text
                    .Add("@OutDate", OleDbType.DBDate).Value = txtOutDt.Text
                    .Add("@AddPay", OleDbType.Integer).Value = txtAdvPay.Text
                    .Add("@Stat", OleDbType.VarChar).Value = "Yes"
                End With
                MsgBox(Com.CommandText)
                MsgBox(Com.Parameters)
                Com.ExecuteNonQuery()
                Com.Parameters.Clear()

this is the code its properly worked

Com.CommandText = "Insert into tblCustomer Values(?,?,?,?,?,?,?,?,?,?,?)"
            With Com.Parameters
                .Add("@CID", OleDbType.VarChar).Value = txtCustID.Text
                .Add("@CName", OleDbType.VarChar).Value = txtCustName.Text
                .Add("@Gender", OleDbType.VarChar).Value = cboGender.Text
                .Add("@DOB", OleDbType.VarChar).Value = cboDOB.Text
                .Add("@Address", OleDbType.VarChar).Value = txtAddress.Text
                .Add("@City", OleDbType.VarChar).Value = txtCity.Text
                .Add("@State", OleDbType.VarChar).Value = txtState.Text
                .Add("@Country", OleDbType.VarChar).Value = txtCountry.Text
                .Add("@Nationality", OleDbType.VarChar).Value = txtNationality.Text
                .Add("@IDType", OleDbType.VarChar).Value = cmbIDType.Text
                .Add("@IDNo", OleDbType.VarChar).Value = txtCardNo.Text
            End With
            ' MsgBox(Com)
            Com.ExecuteNonQuery()

please try to help me to solve this matter

Thanks in Advanced
Nelson Rodrigo

This might not help you much; since looks like Ok from the code posted above. Can you check if the table tblReservation in the database has as many (8 or more) columns as you are inserting here? If there are 7 or less columns, this will cause error.
Also I am not aware if there is "not null" constraint that applies to your database. If it does and if you are ignoring not-nullable columns, that too can cause some error.
Hope it helps.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.