cannot see problem with my dataAdapter insert statement

fguihen

Well-known member
Joined
Nov 10, 2003
Messages
248
Location
Eire
visual studio is telling me that there is something wrong with my insert command for this data adapter and keeps throwing an error when i try to insert a

row. can anyone see any problems with this code? the error simply says there is a problem with the insert into statement, but i cant see any problems.
in the table, all fielts are text fields( as it is an access database) except the "text" field which is a yes/no field.

this is the code to create the insert command for the data adapter:
Code:
this.daContact.InsertCommand = conn.CreateCommand();
			this.daContact.InsertCommand.CommandText = "insert into contact_details(patient_id,home_phone,mobile_phone,address,email,text) "+
													

"values(@patient_id,@home_phone,@mobile_phone,@address,@email,@text)";
			this.daContact.InsertCommand.Parameters.Add("@patient_id",OleDbType.VarChar,50,"patient_id");
			this.daContact.InsertCommand.Parameters.Add("@home_phone",OleDbType.VarChar,20,"home_phone");
			this.daContact.InsertCommand.Parameters.Add("@mobile_phone",OleDbType.VarChar,20,"mobile_phone");
			this.daContact.InsertCommand.Parameters.Add("@address",OleDbType.VarChar,120,"address");
			this.daContact.InsertCommand.Parameters.Add("@email",OleDbType.VarChar,120,"email");
			this.daContact.InsertCommand.Parameters.Add("@text",OleDbType.Boolean,1,"text");

here is the code that creates the row that will be inserted:
Code:
contactRow = ds.Tables["contact_details"].NewRow();
				contactRow["patient_id"] = guid;
				contactRow["home_phone"] = this.txthomePhone.Text;
				contactRow["mobile_phone"] = this.txtMobilePhone.Text;
				contactRow["address"] = this.txtAddress.Text;
				contactRow["email"] = this.txtEmail.Text;
				contactRow["text"] = this.chkText.Enabled;

				ds.Tables["contact_details"].Rows.Add(contactRow);
 
Back
Top