PDA

Click to See Complete Forum and Search --> : Insert record script


CookieNZ
Jun 12th, 2002, 05:12 PM
I am tring to use an inser sql to update the database.

insertSQL = "INSERT INTO Supportcall(ID,Contact,Description)" & " VALUES(txtcallnumber.text,txtcallcontact.text,txtcalldescription.text)"

where txtcallnumber.text are cells in the form.

When I run the app, the exception message is No Value Given for one or more parameters.

The access 2k table only has the 3 fields outlined above

If I 'manually' insert the record it works fine.

insertSQL = "INSERT INTO Supportcall(ID,Contact,Description)" & " VALUES('2','Fred Atkins','This is the description')"

Furthermore, I have a declared the fields as
dr = dssupport.Tables("Supportcall").NewRow()
dr("ID") = txtcallnumber.Text
dr("Description") = txtcalldescription.Text
dr("Contact") = txtcallcontact.Text

Musician
Jun 12th, 2002, 08:55 PM
It's a bit unclear what exactly you are using to send the update to the database. If you ran that sql statement on the command object it should execute fine. If you are trying to use a DataAdapter and Dataset/DataRow then you have to set the InsertCommand, UpdateCommand, DeleteCommand etc. on the DataAdapter. Your error suggests this as using a DataRow to update data requires an UpdateCommand linking source columns between the DataRow in the DataSet and the parameters in your UpdateCommand. The statement where you specify values works becuase it has no parameters and doesn't go looking for them in the DataRow.

TLawson
Jun 15th, 2002, 08:44 PM
insertSQL = "INSERT INTO Supportcall(ID,Contact,Description)" & " VALUES(txtcallnumber.text,txtcallcontact.text,txtcalldescription.text)"


is what you have... try this instread


insertSQL = "INSERT INTO Supportcall(ID,Contact,Description)" & " VALUES("+txtcallnumber.text+","+txtcallcontact.text+","+txtcalldescription.text+")" :D