[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.NETYou 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 file and then referencing the connection string from your SqlDataSource control. To configure a connection string for ODBC in the Web.config fileOpen 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 element if one does not already exist. Create an added element as a child of the ConnectionStrings element, defining the following attributes: connectionString Assign the connection string that is required by the database you are connecting to, setting the appropriate driver, server name, and authentication information. providerName 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 are used to connect to QuickBooks by using an ODBC provider. To reference the ODBC connection string from a SqlDataSource controlIn the page in 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 that you want to execute for this data control. The syntax of the query depends on the data source you are accessing. ConnectionString Set to the name of the connection string that you created in the Web.config file. ProviderName Set to the name of the provider that you specified in the Web.config file for the corresponding connection string. <asp:SqlDataSource You can now bind other controls, such as the GridView control, to the SqlDataSource control Special NotesI think it might be worthwhile at this point to make sure that IIS, QODBC, and QuickBooks can all talk to each other first before questioning ASP.NET connection types and connection 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. | |
|
I am sorry was a typo error, it should be D:\Dataem1996.qbw
we have correct the path issue.
More details on parameters.
DFQ = Path to company file or . (dot) to indicate currently open company file.
OpenMode = F (Follow Company), M (Multi-user), S (Single-user).
DeveloperCode = This is for users of the OEM version only. It is required to connect to the OEM licensing model. The Code is given to you when you purchase an OEM licensing pack.
ColumnNameLen = This is a number that specifies the maximum length a column name can be. Using this is required in some development environments. Its use will make the returned column names not match the normal defined schema.
Example of simple DSN:
sConnectString = "DSN=Quickbooks Data;OLE DB Services=-2;"
Example of a DSNless connection string:
sConnectString = "Driver={QODBC Driver for QuickBooks};DFQ=C:\Program Files\QODBC Driver for QuickBooks\sample04.qbw;OpenMode=M;OLE DB Services=-2;"
Example using current ADO syntax:
sConnectString = "Provider=MSDASQL.1;Persist Security Info=False;Data Source=QuickBooks Data;OLE DB Services=-2;"