Access field name & brackets problem

  • Thread starter Thread starter Greg
  • Start date Start date
G

Greg

I have an Access db (actually, about 60 of them) that has a table with
a field named Q#. This table gets read into a dataset. In the dataset,
the field is also called Q#. But when I try to update the db, an error
occurs because Access wants the field to be surrounded by brackets -
[Q#] - when written back. I know this is the problem, because if I
change the fieldname to QNum, it works fine.
Using the commandbuilder, or building the INSERT, UPDATE, or DELETE
manually without brackets, the error is "Syntax error in INSERT
statement..." (or UPDATE, etc). When I build them manually with
brackets, the error is "No value given for one or more required
parameters..."
An example of the manual statement is: INSERT INTO QS (Q#, QText)
VALUES(?, ?)
I don't want to change the fieldname in Access because there are so
many db's, and the field is used in many queries, forms, etc. I want
to make all changes to the dataset and update all at once. It works
using cmd.ExecuteNonQuery, but that's not what I want. Is there a way
to get this to work? Thanks.
 
There is a QuotePrefix and a QuoteSuffix propert, which is used by the
command builder to put the correct characters around table and column names
to make queries run.

Set those properties to [ and ], respectively.
 
Back
Top