PRB: DBGrid Does Not Insert Record If Field Name Contains Dash (165432)
The information in this article applies to:
- Microsoft Visual C++, 32-bit Enterprise Edition 5.0
- Microsoft Visual C++, 32-bit Professional Edition 5.0
This article was previously published under Q165432 SYMPTOMS
When you try to add a row to an SQL Server table using DBGrid bound to a
Remote Data Control, you receive the following error message if one of the
table's field names contains a "-":
ODBC error: 37000 [Microsoft][SQL Server Driver]Line2: Incorrect syntax
near '-'
CAUSE
This problem occurs because the Remote Data Objects code is creating a SQL
INSERT statement that doesn't put quotation marks around field names. The
INSERT statement would resemble the following:
INSERT INTO x (id, e-mail)
VALUES (1, 'Eric')
If RDO generated an INSERT statement that used double quotes around the
field name, then the INSERT would work. The following syntax would work:
INSERT INTO x (id, "e-mail")
VALUES (1, 'Eric')
RESOLUTION
Either rename the field so that it doesn't contain a hyphen or do the
updates manually (where the developer creates the proper SQL syntax).
STATUS
This is by design. SQL Server does not support the use of dashes in its
identifiers, including server names, database names, tables, views,
columns, indexes, triggers, procedures, defaults, and rules.
Modification Type: | Major | Last Reviewed: | 10/24/2003 |
---|
Keywords: | kbprb KB165432 |
---|
|