Home   |   Asp.Net 2.0   |   .Net Framework 2.0   |   IIS 6.0   |   Sql Server 2005   |   Visual Basic 2005   |   c# 2005   |   VS 2005   |   Visual Source Safe 2005

MS Dynamics CRM 3.0

SharePoint Portal Server 2003
SharePoint Server 2007
Dynamics NAV
Dynamics CRM
SharePoint Designer 2007
SharePoint Portal Server 2001
Windows SharePoint Services
Windows SharePoint Services 3.0
Project Server 2003
Project Server 2007
Dynamics – Point of Sale
Dynamics AX
Dynamics GP
Dynamics Retail Management System (RMS)
Dynamics SL
SQL Server 2000
Visual Basic .NET 2003
Visual C# .NET 2003
Visual C++ .NET 2003
Visual C++ 2005
Visual SourceSafe 6.0
Windows Server 2003
Windows Server 2003
Outlook 2003
ADO.NET 1.1
ASP.NET 1.0
Visual Studio Team Foundation Server
Visual Studio 2005 Team Edition
Windows Internet Explorer 7
BizTalk Server 2000
BizTalk Server 2002
BizTalk Server 2004
BizTalk Server 2006
Visual Studio 6.0
Access 2000
Access 2002
Access 2003
Access 2007
Access 97
Collaboration Data Objects 2.0
Commerce Server 2002
Content Management Server 2001
Commerce Server 2007
Content Management Server 2002
Data Access Components 2.7
Data Access Components 2.8
DirectX 9.0b
Office Small Business Accounting 2006
Accounting 2007
ActiveSync 4.1
Class Server 2.0
Groove 2007
Windows Vista
Outlook 2007
OneNote 2003
OneNote 2007
Office X for Mac
Zune software
Zune Live
Zoo Tycoon 2
Flight Simulator 2002
Dungeon Siege II

Cervo Technologies
The Right Source to Outsource

Oracle Database FAQS

Sharepoint Portal Server KB

Outlook 2007 Knowledge Base Articles

Data Access Components 2.7 Knowledge Base Articles

When you set the RecordSource property of an ADO Data Control to a different SQL SELECT statement and then try to execute the Refresh method, the following error is returned: Syntax error in FROM clause. which is followed by: Run-time error...


When you set the RecordSource property of an ADO Data Control to a different SQL SELECT statement and then try to execute the Refresh method, the following error is returned:
Syntax error in FROM clause.
which is followed by:
Run-time error '-2147217900(80040e14)':
Method 'Refresh' of object 'IAdodc' failed
or:
Method 'Refresh' of object 'IAdodc' failed when attempting to refresh an ADODC after setting the recordsource property to another value.
The errors occur if the CommandType property of the ADO Data Control is set to adCmdTable.

CAUSE

When the CommandType of the ADO Data Control is set to adCmdTable, "SELECT * From" is automatically prepended to the RecordSource value.

Setting the RecordSource to a table name results in a valid SQL statement, such as SELECT * FROM Tablename.

Setting the RecordSource to a SQL SELECT statement, such as Select * From Tablename, results in a SQL statement of Select * From Select * From Tablename, which is an invalid SQL statement.

RESOLUTION

There are several possible workarounds:
1.Use a table name instead of a SQL SELECT statement for the RecordSource property, so that SELECT * FROM Tablename is generated
2.At design time, use a CommandType value of adCmdUnknown. You could then use a table name at design time, and a SQL SELECT statement at run time
3.At run time, explicitly specify a CommandType of adCmdText or adCmdUnknown, so that SELECT * FROM is not automatically prepended.
4.Certain providers accept SELECT * FROM (SELECT * FROM Tablename) as a valid SELECT statement, so you could try enclosing the SQL SELECT in parentheses. For example, the Jet OLE DB Provider 4.0 accepts this syntax.

MORE INFORMATION

Steps to Reproduce Behavior

1.In Microsoft Visual Basic 6.0, create a new Standard EXE project. Form1 is created by default.
2.From the Project menu, choose Components, and select Microsoft ADO Data Control 6.0 (OLEDB).
3.Place an ADO Data Control and a CommandButton onto Form1.
4.Set the ConnectionString property of the ADO Data Control to use the Nwind.MDB that comes with Visual Basic.
5.Set the RecordSource property to the Customers table. Confirm that the CommandType is type 2 - adCmdTable.
6.Add the following code to the click event for the CommandButton:
' Adodc1.CommandType = adCmdText
Adodc1.RecordSource = "Select * from Employees"
Adodc1.Refresh
					
7.Press the F5 key to execute the code. Click on the CommandButton, and note that the errors are returned on the ADODC1.Refresh line of code. Return to design mode.
8.Uncomment the line that explicitly sets the ADO Data Control'sCommandType to adCmdUnknown. Press the F5 key to execute the code, and note that no error is returned.


APPLIES TO
Microsoft Visual Basic 6.0 Professional Edition
Microsoft Visual Basic 6.0 Enterprise Edition
Microsoft Data Access Components 2.0
Microsoft Data Access Components 2.1
Microsoft Data Access Components 2.1 Service Pack 2
Microsoft Data Access Components 2.1 Service Pack 1
Microsoft Data Access Components 2.1 Service Pack 2
Microsoft Data Access Components 2.5
Microsoft Data Access Components 2.6
Microsoft Data Access Components 2.7

Keywords: 
kbdatabase kbprb KB238279

Copyright © 2004 - 2007 Gridview.org, Inc. All rights reserved. Powered by Smart Web Content Management System