FIX: Double Quotes in Remote View Filter Expression Cause Error (157628)



The information in this article applies to:

  • Microsoft Visual FoxPro for Windows 5.0
  • Microsoft Visual FoxPro for Windows 6.0
  • Microsoft Data Access Components 2.5

This article was previously published under Q157628

SYMPTOMS

If the Filter expression of a remote view uses double quotes, then running or modifying the view causes the following error message:
Connectivity Error........invalid column name....

CAUSE

Microsoft SQL Server version 6.0 and up uses single quotes (') for string constants and double quotes (") for identifiers with spaces like "my table," "my column," and so forth. You must convert double quotes to single quotes in the View Designer, before the example constant is included in the SQL string.

RESOLUTION

Use Single Quotes (' ') instead of Double Quotes (" ").

To make the example under "Steps To Reproduce Behavior" section work, change the Example Expression in the Filter tab to use Single Quotes ('B') instead of Double Quotes ("B"). If you are creating the Remote View programmatically then change the WHERE clause to use single quotes as follows:
   CREATE SQL VIEW test;
     REMOTE CONNECTION "myConn";
     AS SELECT Authors.au_id, Authors.au_lname, Authors.au_fname;
       FROM dbo.authors Authors;
       WHERE Authors.au_lname = 'B'
				

STATUS

This behavior is by design.

MORE INFORMATION

Steps to Reproduce Behavior

  1. Use the 32-Bit ODBC Manager to create a DataSource to the PUBS database on a Microsoft SQL Server.
  2. Open a Database or create a new one.
  3. Create a Remote View based on the DataSource created in step 1.
  4. Add the Authors Table to the View
  5. Select three to four fields from the table
  6. Click the Filter tab, create and select a character type field such as "Authors.au_lname," and select any criteria, for example, "=".
  7. Add A with the double quotes (" ") as the expression.
  8. Right-click the Query Designer and click Run Query from the shortcut menu.
The following error appears:
Connectivity Error [Microsoft][ODBC SQL SERVER DRIVER]
[SQL SERVER]invalid column name 'B'
The same behavior occurs if you create a remote view programmatically. So, instead of the above steps, you can issue the following commands to reproduce this behavior:
   CREATE SQL VIEW test;
     REMOTE CONNECTION "myConn";
     AS SELECT Authors.au_id, Authors.au_lname, Authors.au_fname;
       FROM dbo.authors Authors;
       WHERE Authors.au_lname = "B"
				

Modification Type:MajorLast Reviewed:11/17/2003
Keywords:kbbug kbfix KB157628