Microsoft KB Archive/177947

= You receive a "Syntax error in FROM clause" error message when you use the AppWizard to create a CRecordset class by using the ODBC Text Driver in Visual C++ =

Article ID: 177947

Article Last Modified on 6/2/2005

-

APPLIES TO

 Microsoft Data Access Components 2.5, when used with:  Microsoft Visual C++ 6.0 Enterprise Edition

 Microsoft Visual C++ 5.0 Enterprise Edition

 Microsoft Visual C++ 5.0 Professional Edition

 Microsoft Visual C++ 6.0 Professional Edition</li></ul>

 Microsoft Visual C++ 6.0 Standard Edition</li></ul> </li></ul>

-

<div class="notice_section">

This article was previously published under Q177947

<div class="symptoms_section">

SYMPTOMS
When you use the AppWizard to create a CRecordset class using the ODBC Text Driver, your project will compile. However, when you try to open the recordset, you will get the following error message:

Syntax error in FROM clause.

<div class="cause_section">

CAUSE
The AppWizard incorrectly parses the table as [Table].[txt], instead of as [Table#txt].

<div class="resolution_section">

RESOLUTION
In the CTextDriverSet.cpp implementation file, find the CTextDriverSet::GetDefaultSQL function and change the return value from return _T("[Table].[txt]"); to the following: return _T("[Table#txt]"); Here is the function before the changes: CString CTextDriverSet::GetDefaultSQL {     return _T("[Table].[txt]");

} Here is the function after the changes: CString CTextDriverSet::GetDefaultSQL {     return _T("[Table#txt]"); }

<div class="status_section">

STATUS
Microsoft is researching this problem and will post new information here in the Microsoft Knowledge Base as it becomes available.

<div class="moreinformation_section">

In Notepad
<ol>  Create a text file with the following content: <pre class="fixed_text">     Field1,Field2 1,abc </li> Save this file as Table.txt and close it.</li> Create a new User DSN based on the Microsoft Text Driver and name it TextDriverSample.</li> Clear the Use Current Directory box.</li> Click the Select Directory button and select the directory that contains Table.txt.</li> Click Options.</li> Select *.txt from the Extensions list box.</li> Click the Define Format button.</li> Select Table.txt.</li> Select the Column Name Header box.</li> From the Format combo box, select CSV Delimited.</li> Click the Guess button.</li> Save and exit the ODBC Manager.</li></ol>

Start Visual C++ 5.0 or Visual C++ 6.0

 * 1) Create a new MFC application.
 * 2) Select Single Document, then click Next.
 * 3) Select Database View Without File Support.
 * 4) Click the Data Source button.
 * 5) From the ODBC combo box, select TextDriverSample, then click OK.
 * 6) From the Database Tables list, select Table.txt.
 * 7) Click OK, then click Finish.
 * 8) Compile the project.

Additional query words: Bomb Error

Keywords: kberrmsg kbtshoot kbdatabase kbprb kbmdacnosweep KB177947

-

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

© Microsoft Corporation. All rights reserved.