[QODBC-Desktop] Connection string for ASP.Net
Posted by brad waddell on 12 March 2009 05:21 PM
How to: Connect to a QODBC Database Using ASP.NET
You can use the SqlDataSource control to connect to any database that supports Open Database Connectivity (ODBC) by storing connection string information in the Web application's Web. Config the file and then reference the connection string from your SqlDataSource control.
To configure a connection string for ODBC in the Web. config file
Open the Web. Config file in the root directory of your ASP.NET application. If you do not have a Web. Config file, create one.
In the Configuration element, add a ConnectionStrings component if one does not already exist.
Create an added element as a child of the ConnectionStrings component, defining the following attributes:
connectionString Assign the connection string required by the database you are connecting to, setting the appropriate driver, server name, and authentication information.
provider name Assign the value "System.Data.Odbc", which specifies that ASP.NET should use the ADO.NET System.Data.Odbc provider when making a connection with this connection string.
The connection string configuration will be similar to the following example. In this example, the connection string values to connect to QuickBooks using an ODBC provider.
To reference the ODBC connection string from a SqlDataSource control
On the page on which you want to connect to the QODBC database, add a SqlDataSource control.
In the SqlDataSource control, specify the following properties:
SelectCommand Set to the query you want to execute for this data control. The syntax of the query depends on the data source you are accessing.
ConnectionString Set the name of the connection string you created on the Web. Config file.
ProviderName Set the name of the provider you specified on the Web. Config file for the corresponding connection string.
You can now bind other controls, such as the GridView control, to the SqlDataSource control
I think it might be worthwhile to make sure that IIS, QODBC, and QuickBooks can all talk to each other first before questioning ASP.NET connection types and strings.
See: How to see QuickBooks data in an Internet Explorer Browser using Windows XP for the IIS/QODBC/QuickBooks setup requirements and a simple web example to test.