Knowledgebase
[QODBC-Desktop] Troubleshooting: Error when using QODBC with Visual Studio 2008
Posted by brad waddell on 12 March 2009 05:21 PM

Troubleshooting: Error when using QODBC with Visual Studio 2008

Problem Description

I am trying to use the QODBC connection using Visual Studio 2008.

The 2.1 Compatibility option in QODBC Setup Screen -> Advanced tab is unchecked.

Test Connection works fine. Server Explorer Data Connections works fine.

I attempt to add a new Data Source [Database / ODBC.QODBC / New Connection / Data source: Microsoft ODBC Data Source / Use user or system data source name: QuickBooks Data / Test Connection -> Test connection succeeded. / OK / Next > / Next > / Retrieving Database information. / An error occurred while retrieving the information from the database:

Selecting objects of type 'Procedure' is not supported.

 

Solutions

This is actually a Visual Studio 2008 bug, you will need to install VS2008 SP1.

See: http://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=340176

For those who use the 64-bit system

And please notice if you are using a 64-bit system, specify x86 as Target CPU in Visual Studio 2008.

Change project properties| Advanced Compile Options... | Target CPU | x86

When this was done, the sample code (below) worked.

Sample Code

You should still be able to connect to the ODBC data source using the OdbcConnection class (http://msdn2.microsoft.com/en-us/library/system.data.odbc.odbcconnection.aspx).

The following code is the minimal code required to create a DataSet from the SQL statement and attaches the dataset to a DataGrid:

Dim cnQODBC As System.Data.Odbc.OdbcConnection
Dim daQODBC As System.Data.Odbc.OdbcDataAdapter
Dim dsQODBC As System.Data.DataSet

cnQODBC = New System.Data.Odbc.OdbcConnection("DSN=QuickBooks Data")
cnQODBC.Open()
daQODBC = New System.Data.Odbc.OdbcDataAdapter("SELECT ListID, FullName, CompanyName FROM Customer", cnQODBC)
dsQODBC = New System.Data.DataSet

daQODBC.Fill(dsQODBC)
dgDataGrid.DataSource = dsQODBC
dgDataGrid.DataBind() 'May or may not be required depending on where you put this code.

(108 vote(s))
Helpful
Not helpful

Comments (1)
Ving
20 September 2012 10:49 AM
Ah, i see. Well that's not too tirkcy at all!"
Post a new comment
 
 
Full Name:
Email:
Comments:
CAPTCHA Verification 
 
Please complete the captcha below (we use this to prevent automated submissions).