How can I dig deeper to find the actual promblem?

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

VB.NET 2003

I am battling with a specific procedure that does not allow me to update my
data adapter due to an apparent syntax error. I created the data adapter
usign the drag and drop method (from the Server Explorer to the form) by
dragging the table in question to the form and then generating the dataset.

In a procedure I add records to the problem table based on values in other
datagrids in the following way:

Dim drw As DataRow = DataSet51.Tables("InfluenceValues").NewRow()
drw(0) = DataGrid2.Item(DataGrid2.CurrentRowIndex, 0)
drw(1) = DataGrid3.Item(DataGrid3.CurrentRowIndex, 1)
...
drw(9) = 0 '{zero}
drw(10) = 0 '{zero}
DataSet51.Tables("InfluenceValues").Rows.Add(drw)


The added records display correctly in my datagrid and does not raise any
errors. The added records also match the existing records (execpt for one
column which has unique values).

When I (try to) update the data adapter

OleDbDataAdapter8.Update(DataSet51, "InfluenceValues")

I get the error:

System.Data.OleDb.OleDbException
Syntax error in INSERT INTO statement.

The automatically generated INSERT INTO statement reads as follows:

INSERT INTO InfluenceValues (Var1, Var2, Var3, Var4, Var5, Var6, Var7, Var8,
Var9, Var10, Var11) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)

Adding the exact same record manually into the actual database works
perfect, but even doing it manually into the datagrid gives the same error
when trying to update.

So, the error can't be in the syntax.

Using a error trap and messagbox, I derived the following additional info:

err.source = Microsoft JET Database Engine
err.targetsite = Int32 Update(System.Data.DataRow[],......

The above left me with the idea that it has to do with the 'double' value
columns (numbers) but since the data adapter creates the supporting code
itself, I can't immagine why it wouldn't accept any of the numbers I enter (I
even tried putting the zeros in quotes ("") and also tried setting the value
equal to a value allready in the database table)

How can I get more info to identify the actual problem?
 
Regarding the INSERT statement you posted, are the actual variable name
Var1, Var2, etc?

I suspect that maybe you have a field in your database that is the same
as a reserved keyword. Have you checked this possibility?
 
Wow - I would never have thought!

No, the var1 etc were only examples.

I changed all the 'suspicious' field names by adding a number and it works
perfectly!! You saved me from a number of sleepless nights!

By the way, whithout me trying them all one by one and recreating the
adapters and dataset again, which one of the following field names could have
been the culpret:

Terrain
Day
Moon
Night

Thanks again!!!
 
Back
Top