I'm getting the following error after running my code:
OleDbException was unhandled
"No of query values and destination fields are not the same" Because of this query I'm unable to save data.
Please help, what could be the reason?
=======================================
Here is a part of the code which could be causing the problem:
private void button1_Click(object sender, EventArgs e)
{
OleDbCommand cmd = new OleDbCommand();
cmd.CommandType= CommandType.Text;
cmd.CommandText=" Insert into InterviewDatabase(Participant_ID,Accepted,Not_Accepted,Interview_Comments,Last_Name,First_Name,Middle_Init,D_O_B,Age,SS_Number,DL_ID,State,Race_Ethinicity,Marital_Status,No_of_Dependents,Referred_by,Previous_participant,No_of_times,Date_Interviewed,Interviewer_no_one,Interviewer_no_two,Primary_Addiction,Last_Used_one,Injection_User,Secondary_Addiction,Last_Used_two,Tertiary_Addiction,Last_Used_three,Employed,Homeless,Taking_Meds,Waiver) Values ('"+textBox1+"','"+comboBox1+"','"+textBox2+"','"+interviewcomment+"','"+lastname+"','"+FIRSTname+"','"+MIDDLEinit+"','"+Dateofbirth+"','"+Age+"','"+SSN+"','"+dlid+"','"+state+"','"+raceethnicity+"','"+maritalstatus+"','"+noofdependents+"''"+referredby+"','"+previousparticipant+"','"+nooftimes+"','"+dateinterviewed+"','"+interviewerone+"','"+interviewertwo+"','"+primaryaddiction+"','"+lastusedone+"','"+injectionuser+"','"+secondaryaddiction+"','"+lastusedtwo+"','"+tertiaryaddiction+"','"+lastusedthree+"','"+employed+"','"+homeless+"','"+takingmeds+"','"+waiver+"')" ;
cmd.Connection=myCon;
myCon.Open();
cmd.ExecuteNonQuery();
myCon.Close();
}
The Participant_ID in Insert Into ( ) corresponds to textBox1 in Values ( ).
And I'm extracting the user input for Participant_ID as ' " +textBox1+ " ' . Isn't it correct?
Please correct me if I'm wrong.
Please find the attached image file of the message.
Thanks