By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
444,239 Members | 1,505 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 444,239 IT Pros & Developers. It's quick & easy.

Number of query values and destination fields are not the same

P: 1
Expand|Select|Wrap|Line Numbers
  1. If str = "add" Then
  2.             ''''''ADD NEW RECORD'''''''
  3.             If txtID.Text = "" Or txtFirst.Text = "" Or txtLast.Text = "" Or txtAddress.Text = "" Or TextBox2.Text = "" Or TextBox3.Text = "" Or TextBox4.Text = "" Or TextBox5.Text = "" Or TextBox6.Text = "" Or TextBox7.Text = "" Or TextBox8.Text = "" Or TextBox9.Text = "" Or TextBox10.Text = "" Or TextBox11.Text = "" Or TextBox12.Text = "" Or TextBox13.Text = "" Or TextBox14.Text = "" Or TextBox15.Text = "" Or TextBox16.Text = "" Then
  4.  
  5.                 MessageBox.Show("All fields Are Required", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
  6.             Else
  7.                 myqry = "INSERT INTO  main (ML,DEVICE,LOT,QTY,GATING,DATE1,PKGTYP,DEVICE_NO,LOT_NO,SHELF,ACTUAL_P,E_RETURN,S_RETURN,VARIANCE,VARIANCE_REC,PULLEDBY,RETURN_TD,PROCESSBY,LOCATED,REASON) "
  8.                 myqry = myqry + " VALUES('" & txtID.Text & "','" & txtFirst.Text & "','" & txtLast.Text & "','" & txtAddress.Text & "','" & TextBox2.Text & "','" & TextBox3.Text & "','" & TextBox4.Text & "','" & TextBox5.Text & "','" & TextBox6.Text & "','" & TextBox7.Text & "','" & TextBox8.Text & "','" & TextBox9.Text & "','" & TextBox10.Text & "','" & TextBox11.Text & "','" & TextBox12.Text & "','" & TextBox13.Text & "','" & TextBox14.Text & "','" & TextBox15.Text & "','" & TextBox16.Text & "')"
  9.                 mycmd = New OleDbCommand
  10.                 With mycmd
  11.                     .CommandText = myqry
  12.                     .Connection = conn
  13.                     .ExecuteNonQuery()
  14.                 End With
  15.                 Call Set1()
  16.             End If
Jul 24 '13 #1
Share this Question
Share on Google+
1 Reply


Expert 5K+
P: 8,434
Actually, this is an easy one. The error message (for once) tells you exactly what's wrong.

In your SQL INSERT statement, you have provided 19 values to be placed in 20 fields.
Jul 24 '13 #2

Post your reply

Sign in to post your reply or Sign up for a free account.