PDA

View Full Version : Need help adding a record to a table


JoshuaLuke
02-16-2003, 07:31 AM
I've included a link to my cs file in rtf format and will highlite the pertinent functions with bold.

Basically, I have the data in one table in an mdb and access it using oledb and load it into a DataSet. Then I use a command builder to create all the sql (and I have tried it manually as well) and everything works except for the insert command; delete, select, and update all work.

The error I get is:

System.Data.OleDb.OleDbException: Syntax error in INSERT INTO statement.
at System.Data.Common.DbDataAdapter.Update(DataRow[] dataRows, DataTableMapping tableMapping)
at System.Data.Common.DbDataAdapter.Update(DataTable dataTable)
at ssbg.sv.ButtonAdd_Click(Object sender, EventArgs e)

I'm stumped, please help.

Table details:

ProductID (AutoNumber, also primary key)
Title (text)
Image (text)
Visible (Yes/No)
Price (double, currency)
Monogram (double, currency)
Shipping (double, currency)
MonoMaxLines (integer)
MonoMaxChars (integer)
Description (memo)

The field types are the Access definition, not the C# defs.

Here is the link for the source code file:
www.thyword.info/ssbg/db.rtf (http://www.thyword.info/ssbg/db.rtf)

acsmedic
03-03-2003, 01:26 AM
I had same problem.. I solved it by placeing the table name into the field names of the database.

for a table named home and fields hi and bye:

home_hi
home_bye

this is dependent on the method that you are using, will work if you are using the IDE but will not if hand coding

Taylor