Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Problem using DropDownList.DataValueField

Status
Not open for further replies.

TheDust

Programmer
Aug 12, 2002
217
US
I am trying to execute an INSERT statement on an Access database, but I'm gettting the error that the number of query values and destination fields are not the same. The query is rather lengthy, but here is where I believe the problem to be...

txtCity.Text + "', " + ddState.DataValueField + ", " + txtZip.Text

Since the value I'm extracting is an integer, I'm leaving it without quotes. Does anyone know what I'm doing wrong here? (The entire query is listed below)

OleDbCommand myCommand = new OleDbCommand(("INSERT INTO contacts (firstName, lastName, street1, street2, city, stateID, workPhone, homePhone, email) VALUES ('" + txtFirstName.Text + "', '" + txtLastName.Text + "', '" + txtStreet1.Text + "', '" + txtStreet2 + "', '" + txtCity.Text + "', " + ddState.DataValueField + ", '" + txtZip.Text + ", " + txtWorkPhone.Text + ", " + txtHomePhone.Text + ", '" + txtEmail.Text + "'"), objConnection);
 
your missing zip in the column specifications of your insert statement
 
Cripes... alright. I think it's time for me to finish this up and take a break from it... ha... a little embarassing, but thanks for the second set of eyes!

Dust
 
definitely a sign that you have been working too hard... =)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top