Notice: This website is an unofficial Microsoft Knowledge Base (hereinafter KB) archive and is intended to provide a reliable access to deleted content from Microsoft KB. All KB articles are owned by Microsoft Corporation. Read full disclaimer for more details.

ACC2000: ODBC Error with Pass-Through Update Query


View products that this article applies to.

This article was previously published under Q208481
This article applies only to a Microsoft Access database (.mdb).

Moderate: Requires basic macro, coding, and interoperability skills.

↑ Back to the top


Symptoms

When you use quotation marks ("") around the values in a pass-through update query, or you send a string that contains an apostrophe (') to Microsoft SQL Server, you may receive the following ODBC error:
ODBC--call failed.

[Microsoft][ODBC SQL Server Driver][SQL Server]Invalid column name '<value>'. (#207)

↑ Back to the top


Cause

Beginning with SQL Server 6.0, Microsoft introduced support for ANSI SQL quoted identifiers. Clients can set a connection option asking the server to enforce the ANSI quoted identifier rules for SQL commands sent to it over that connection. ANSI SQL expects quotation marks (") to enclose identifiers, and apostrophes (') to enclose character string data values. Quotation marks are the identifier delimiter in ANSI SQL, not the string delimiter. In order for this to be a valid pass-through query, you must use apostrophes.

↑ Back to the top


Resolution

Use apostrophes around your values instead of quotation marks. Also, if the string that you are sending already contains an apostrophe, use two apostrophes instead of just one. For example, if you were passing the last name of O'Brien, you would precede the apostrophe with two additional apostrophes (that is, 'O''Brien').
UPDATE authors SET au_lname = 'O''Brien', au_fname = 'John', phone = '999-999-0000' WHERE au_id = '527-72-3246';
				

↑ Back to the top


More information

When you use quotation marks ("") around the values in a pass-through update query, or you send a string that contains an apostrophe (') to Microsoft SQL Server, you receive an ODBC call failed error.

This error does not occur when you use the ISQL/W tool with the Microsoft SQL Server client utilities. The reason for the different behavior between ISQL/W and the pass-through query is that ISQL/W uses DB-LIB, which has a different default behavior than the Microsoft SQL Server ODBC driver that is used by the pass-through query. The ODBC driver sets QUOTED_IDENTIFIERS ON when it runs against a Microsoft SQL Server, so that the driver's behavior more closely matches the ANSI and ODBC standards. DB-Library clients, such as ISQL/W, can exhibit this failed behavior if they issue a SET QUOTED_IDENTIFIER ON command.

Steps to Reproduce Behavior

  1. Create a new Data Source Name (DSN) that points to a Microsoft SQL Server and specify the Pubs database.
  2. After creating the DSN, start Microsoft Access, open any database, and then create a new query in Design View. Do not select any tables.
  3. On the Query menu, point to SQL Specific, and then click Pass-Through. You should see a blank window with the title Query1:SQL Pass-Through Query.
  4. On the View menu, click Properties.
  5. In the Query Properties dialog box, click the ODBC Connect Str property, click the Build button, select your DSN, and then log onto the SQL Server.
  6. On the property sheet, set the Returns Records property to No.
  7. Close the property sheet, and then enter the following in the Query1:SQL Pass-Through Query window:
    UPDATE authors SET au_lname = "Doe", au_fname = "John", phone = "999-999-0000" WHERE au_id = "527-72-3246";
    					
  8. Run the query. Note that you receive the error message mentioned in the "Symptoms" section of this article.
NOTE: Microsoft Access 2000 only supports connectivity to SQL Server 6.5 or higher.

↑ Back to the top


References

For more information about creating ODBC connections for pass-through queries, click Microsoft Access Help on the Help menu, type create the odbc connection string for an sql pass-through query in the Office Assistant or the Answer Wizard, and then click Search to view the topics returned.

For more information about controlling SQL Server through pass-through queries, click Microsoft Access Help on the Help menu, type send commands to an sql database using a pass-through query in the Office Assistant or the Answer Wizard, and then click Search to view the topics returned.

↑ Back to the top


Keywords: KB208481, kbprb, kbinterop, kberrmsg

↑ Back to the top

Article Info
Article ID : 208481
Revision : 2
Created on : 6/30/2004
Published on : 6/30/2004
Exists online : False
Views : 281