Microsoft KB Archive/190113

= BUG: Query Designer Generates Invalid SQL Statement =

Article ID: 190113

Article Last Modified on 10/23/2000

-

APPLIES TO


 * Microsoft Visual Basic 6.0 Enterprise Edition

-



This article was previously published under Q190113



SYMPTOMS
Under certain conditions, the Query Designer may generate invalid SQL statement if database is MDB file. When the statement is executed, VB generates the error:

Syntax error in FROM clause



RESOLUTION
Manually remove the braces "{}" and "oj" from the "From" statement.

Code Example
Change the following statement

SELECT Products.ProductName, `Order Details`.Quantity FROM { oj `Order Details` LEFT OUTER JOIN Products ON `Order Details`.ProductID = Products.ProductID }

To the following:

SELECT Products.ProductName, `Order Details`.Quantity FROM `Order Details` LEFT OUTER JOIN Products ON `Order Details`.ProductID = Products.ProductID



STATUS
Microsoft has confirmed this to be a bug in the Microsoft products listed at the beginning of this article. We are researching this bug and will post new information here in the Microsoft Knowledge Base as it becomes available.



Steps to Reproduce Behavior

 * 1) Open Visual Basic and create a new Standard EXE project.
 * 2) On the Project menu, click Add a Data Environment.
 * 3) Right click the connection, select Properties, and select OLEDB Provider for Jet 3.51.
 * 4) Click the Connection tab and select the NWind.mdb by using the ellipsis button for item 1.
 * 5) Right-click the connection and select "Add a Command."
 * 6) Right-click Command1; select "SQL" as data source. Click SQL Build to launch the Query Designer.
 * 7) Drag-drop Table "Order Details" and "Products" onto the diagram pane; there is a relationship between these two tables.
 * 8) Check the column "ProductName" in Products and column "Quantity" in "Order Details."
 * 9) Right-click the relationship line and select "select all rows from 'Order Details'."

RESULT: The SQL sentence in the SQL pane is:

SELECT Products.ProductName, 'Order Details'.Quantity FROM { oj 'Order Details' LEFT OUTER JOIN Products ON 'Order Details'.ProductID = Products.ProductID }

This is an invalid SQL statement; when running it, Visual Basic generates "Syntax error in FROM clause" when it attempts to save the query.

Additional query words: kbvbp600bug kbdse kbDSupport kbVBp

Keywords: kbbug KB190113

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.