Member Login

Username
Password
Forget Password
New Sign Up
Search Forum

Buy Support
Incidents

If you can't find your answer in the FREE PUBLIC QDeveloper Forum, require URGENT Priority Support, or you need to send us private or confidential information:

Click Here
If you can't login and post questions or you are having trouble viewing forum posts:
Click Here
Callback
Support

If you live in USA, UK, Canada, Australia or New Zealand, you can leave us details on your question and request us to call you back and discuss them with you personally  (charges apply).

Click Here
 
Buy Support
Incidents
If you can't find your answer in the FREE PUBLIC QDeveloper Forum, require URGENT Priority Support, or you need to send us private or confidential information:
Click Here

Forum : Connection string for ASP.NetSearch Forum

Forum Home > QODBC - ODBC Driver for QuickBooks > QODBC v6 Forum

 New Topic 
 
 Post Reply 
[1]  
 Connection string for ASP.Net 
 Author   Message 
  Andrew Baldwin 
  
 Group: Members 
 Posts: 3 
 Joined: 2006-05-16 
 Profile
 Posted : 2006-05-16 05:31:06

I am using the following connection string after trying the ones that Tom gave out. This one was automatically generated for me when I connected Visual Web Developer to the OLE DB. It has problems retrieving the data from the tables, but I am not really concerned about that. I just want to be able to get in. We are currently evaluating the product and we are really excited about the possibilites and will be purchasing it as soon as we can get it working under our SQL Server 2003 environment. I have run the VB tester on the server and it works like a champ in there. I set the UseDCOM in the Driver settings in DataSources (ODBC), I have never used a DSN in a connection string before though, so I may have something wrong in there.

string DSN = @"Provider=SQLOLEDB;DRIVER={QODBC Driver for QuickBooks};DSN=QuickBooks Data;DFQ=D:\Data\em1996.qbw;SERVER=server4;UseDCOM=Y;OpenMode=F;OptimizerDBFolder=C:\Program Files\QODBC Driver for QuickBooks\Optimizer;";

I get the following exeption:

Message:
Invalid authorization specification
Invalid connection string attribute

Source:
Microsoft OLE DB Provider for SQL Server

Any ideas guys?

AB

 

 
~~ Insert clever signature here ~~

** This space for rent ** 
 
  Top 
  Tom 
  6c3c1_sdk-qodbc.gif
 Group: Administrator 
 Posts: 5510 
 Joined: 2006-02-17 
 Profile
 Posted : 2006-05-16 08:57:54

ASP.NET
How to: Connect to an QODBC Database Using the SqlDataSource Control

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 file and then referencing 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 element if one does not already exist.

Create an add element as a child of the ConnectionStrings element, defining the following attributes:

name Set the value to the name that you want to use to reference the connection string.

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.

<configuration>
    <connectionStrings>
        <add
            name="QODBCDataConnectionString"
            connectionString="DRIVER={QODBC Driver for QuickBooks};DFQ=D:\Data\em1996.qbw;SERVER=QODBC;UseDCOM=Y;OpenMode=F;"
            providerName="System.Data.Odbc"
        />
    </connectionStrings>
</configuration>


Save the Web.config file and close it.


To reference the ODBC connection string from a SqlDataSource control
In 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.

Note:  You can also define UpdateCommand, InsertCommand, and DeleteCommand properties. The SqlDataSource control supports commands and functionality not covered here.

The following example shows a SqlDataSource control configured to access the QODBC data source. In the example, the SelectCommand property is set to a SQL query.

<asp:SqlDataSource
    ID="SqlDataSource1"
    Runat="server"
    SelectCommand="Select * From Customer"
    ConnectionString="<%$ ConnectionStrings:QODBCDataConnectionString %>"
    ProviderName="<%$ ConnectionStrings:QODBCDataConnectionString.ProviderName %>" />

You can now bind other controls, such as the GridView control, to the SqlDataSource control.


 

  Top 
  Andrew Baldwin 
  
 Group: Members 
 Posts: 3 
 Joined: 2006-05-16 
 Profile
 Posted : 2006-05-17 03:42:35
Ok, still no good. I tried the code that you suggested and I am getting further. I was using an OleDbConnection object earlier, so the connection string was being rejected based off of that.

First off, is the desired result of the DCOM VBS Script? I checked the permissions in DCOMCNFG and they look all set correct...

---------------------------
QODBC Set DCOM Security
---------------------------
qbXMLRPEQODBInteractive Settings
  Launch Allowed:
    AUSTIN\Andrew Baldwin NT AUTHORITY\SYSTEM NT AUTHORITY\INTERACTIVE SERVER4\ASPNET SERVER4\IIS_WPG
  Launch Denied:
   

  Access Allowed:
    AUSTIN\Andrew Baldwin NT AUTHORITY\SYSTEM NT AUTHORITY\INTERACTIVE SERVER4\ASPNET SERVER4\IIS_WPG
  Access Denied:
   

qbXMLRP2EQODBInteractive Settings
  Launch Allowed:
    AUSTIN\Andrew Baldwin NT AUTHORITY\SYSTEM NT AUTHORITY\INTERACTIVE SERVER4\ASPNET SERVER4\IIS_WPG
  Launch Denied:
   

  Access Allowed:
    AUSTIN\Andrew Baldwin NT AUTHORITY\SYSTEM NT AUTHORITY\INTERACTIVE SERVER4\ASPNET SERVER4\IIS_WPG
  Access Denied:
   
---------------------------
OK  
---------------------------

Here is the code that I am trying to use. I don't like storing connection strings and whatnot in the web.config, I also will need to do more than use an SqlDataSource, specifically a SqlDataAdapter, so I modified what you were saying to do to reflect in the codebehind file. I think that the problem lies somewhere in the DCOM deal, because my webpage simply hangs, and nothing happens, where using the VB Tester that you provide actually causes Quickbooks to open. Either way, here is the code that I am running. Incidentally, this is a Windows Server 2003 environment with IIS 6, again, I think that this is an IIS problem, not a code problem. This is the same stumbling block that I came to in my attempt to use the SDK directly (no answer on their forums, but here is my post to them, that should give you more info http://idnforums.intuit.com/messageview.aspx?catid=9&threadid=5691 ). Any ideas on how to get this com thing working on Server 2003?


using System;
using System.Data.Odbc;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

public partial class _Default : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {

            string DSN = @"Provider=System.Data.Odbc;DRIVER={QODBC Driver for QuickBooks};DFQ=D:\Data\em1996.qbw;SERVER=QODBC;UseDCOM=Y;OpenMode=F;DSN=Quickbooks Data;OLE DB Services=-2;";
             // This DSN also simply freezes.
             // string DSN = @"Provider=System.Data.Odbc;DSN=Quickbooks Data;OLE DB Services=-2;";

            OdbcConnection conn = new OdbcConnection(DSN);           
            OdbcDataAdapter da = new OdbcDataAdapter("select top 50 * from customers", DSN);
            DataSet ds = new DataSet();
            da.Fill(ds);
            _Content.Text = "<table>";
            foreach (DataRow dr in ds.Tables[0].Rows) {
                _Content.Text += "<tr><td>" + (string)dr["CompanyName"] + "</td></tr>";

            }
            _Content.Text += "</table>";
       
        }

 
~~ Insert clever signature here ~~

** This space for rent ** 
 
  Top 
  Tom 
  6c3c1_sdk-qodbc.gif
 Group: Administrator 
 Posts: 5510 
 Joined: 2006-02-17 
 Profile
 Posted : 2006-05-17 10:29:08

While your focus has been on how or on how you don't want to use ASP.NET, I 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 can I see QuickBooks data in a Internet Explorer Browser using Windows XP? for the IIS/QODBC/QuickBooks setup requirements and a simple web example to test.

 

  Top 
  jeff 
  
 Group: Members 
 Posts: 76 
 Joined: 2006-06-03 
 Profile
 Posted : 2006-11-04 12:22:23

I have attempted to create an asp.net applicatio that runs the following sql : "select * from Customer".

The testdcom.asp works perfectly and successfully. However when running in asp.net I always receive the following error when openning a connection;

ERROR [00000] [QODBC] QB Open Connection Failed. Create DCOM Instance Error = 80070005, Unknown error.. Created qbXMLRP2 OK. ERROR [00000] [QODBC] QB Open Connection Failed. Create DCOM Instance Error = 80070005, Unknown error.. Created qbXMLRP2 OK.

Also QBCust.asp works perfectly. Do you have any idea why asp.net cannot create an instance of the dcom server exectuables?

Do you have a working asp.net project or file that I could download?

I am using iis 5.0 and the version 7.0 of qodbc.

 

  Top 
  Tom 
  6c3c1_sdk-qodbc.gif
 Group: Administrator 
 Posts: 5510 
 Joined: 2006-02-17 
 Profile
 Posted : 2006-11-04 17:33:25
All I have is this, click the link below, uncompress the zip archive, then open and run the project: http://qodbc.com/docs/support/QODBCDemoforDotNet.zip  

  Top 
  jeff 
  
 Group: Members 
 Posts: 76 
 Joined: 2006-06-03 
 Profile
 Posted : 2006-11-07 05:11:48
Sorry, I've already got that project. Writing a windows application with the qodbc works fine and is easy to do. I'm asking for an asp.net project file. If you don't have one, then how about addressing the issues in my last thread. Why am I getting errors from qodbc when running in asp.net? Classic asp works fine and so does the testdcom.asp. Please shed some light on the situation. 

  Top 
  Tom 
  6c3c1_sdk-qodbc.gif
 Group: Administrator 
 Posts: 5510 
 Joined: 2006-02-17 
 Profile
 Posted : 2006-11-07 10:51:23

You have QODBC working from your .asp webpages, so it appears that your DCOMs are running. This looks wrong:

string DSN = @"Provider=System.Data.Odbc;DRIVER={QODBC Driver for QuickBooks};DFQ=D:\Data\em1996.qbw;SERVER=QODBC;UseDCOM=Y;OpenMode=F;DSN=Quickbooks Data;OLE DB Services=-2;";

should be:-

string DSN = @"Provider=System.Data.Odbc;DRIVER={QODBC Driver for QuickBooks};DFQ=D:\Data\em1996.qbw;SERVER=QODBC;UseDCOM=Y;OpenMode=F;";

 

  Top 
  jeff 
  
 Group: Members 
 Posts: 76 
 Joined: 2006-06-03 
 Profile
 Posted : 2006-11-07 13:31:13

I have attempted to use : "Provider=System.Data.Odbc;DRIVER={QODBC Driver for QuickBooks};DFQ=C:\Program Files\Intuit\QuickBooks Enterprise Solutions 6.0\sample_service-based business.qbw;SERVER=QODBC;UseDCOM=Y;OpenMode=F" as the connection string.

I still receive the same error. I have a hunch that maybe there is a communication issue with qodbc when using IIS and ASP.NET when using the DCOM Servers. Can you reproduce the same error? The exception is thrown when "connection.Open();" is called.

 

 

 

 

  Top 
  Tom 
  6c3c1_sdk-qodbc.gif
 Group: Administrator 
 Posts: 5510 
 Joined: 2006-02-17 
 Profile
 Posted : 2006-11-07 15:03:44
There are known issues when using the DCOMs as to whether you need to setup them to use the Interactive user or the launching user and it also depends on the QuickBooks year version you are using. 

  Top 
 New Topic 
 
 Post Reply 
[1]  

Jump to