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 : insert via ODBC driver from.NET slow, VB demo is fastSearch Forum

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

 New Topic 
 
 Post Reply 
[1]  
 insert via ODBC driver from.NET slow, VB demo is fast 
 Author   Message 
  SN 
  
 Group: Members 
 Posts: 3 
 Joined: 2007-09-11 
 Profile
 Posted : 2007-09-11 03:00:07

I have the following insert which executes in < 1 sec in the VB Demo tool but takes 4 - 5 from the .NET code. I open the connection once and perform all the operations (inserting several sales orders) on the same connection.

insert into SalesReceiptLine (RefNumber, TxnDate, DueDate, CustomerRefFullName, ClassRefFullName,
 Memo,  PaymentMethodRefFullName, CustomerSalesTaxCodeRefFullName, ItemSalesTaxRefFullName,  SalesReceiptLineItemRefFullName, SalesReceiptLineDesc, SalesreceiptLineQuantity, SalesreceiptLineRate,   SalesreceiptLineClassRefFullName, SalesreceiptLineAmount, SalesreceiptLineSalesTaxCodeRefFullname)
Values ( 'SO100004',{ d'2007-09-05'},{d '2007-09-05'},'OTC Consultant','TX','CustName',NULL
,'Tax', 'BlueNet Sales Tax', '4200','Port Authority - White w/  Visor',3,14.99,'TX',44.97,'Tax')

My selects and even deletes (i use Jump-Ins in the where clause) happen very fast. I am puzzled as to why the inserts should take so long. I don't know how to analyse the performance further. Is there some place (like SQL trace) where I can look to see which sub operation is taking long?

 

  Top 
  Tom 
  6c3c1_sdk-qodbc.gif
 Group: Administrator 
 Posts: 5510 
 Joined: 2006-02-17 
 Profile
 Posted : 2007-09-11 09:26:50

Try looking at: ASP.NET vs Classic ASP 

 

  Top 
  SN 
  
 Group: Members 
 Posts: 3 
 Joined: 2007-09-11 
 Profile
 Posted : 2007-09-12 09:56:09

Thank you. The post refers to ASP.NET and I am trying this from a C# .NET Windows Console application. I am guessing the VB Demo app was written in VB 6.0. So, I tried the same insert using VB6 using ADO library and the insert ran quite fast (<1 sec). Are you aware of some settings in .NET ODBC connection or command that is causing the delay? When I turn on the QODBC trace, the insert statement is causing "Open table" operation on Sales ReceiptLine table which is taking upto 6 seconds and longer sometimes (basically all the delay is from this Open table operation) . The same operation shows up even from VB6 but completes immediately. Here is the code in C# .NET that I am using. Thanks!

OdbcConnection conn = new OdbcConnection(QBConnectString);

conn.ConnectionTimeout = 300;

conn.Open();

OdbcCommand command = new OdbcCommand("insert into ......");

command.CommandTimeout = 300;

command.Connection = conn;

command.ExecuteNonQuery();

 

  Top 
  Tom 
  6c3c1_sdk-qodbc.gif
 Group: Administrator 
 Posts: 5510 
 Joined: 2006-02-17 
 Profile
 Posted : 2007-09-12 10:03:54
Your C# .NET Windows Console application needs to use a STA (single-threaded-apartment) threading model. Multi-threading actually slows QODBC down as we need to re-establish a connection to QuickBooks every time the Thread ID changes.  

  Top 
  SN 
  
 Group: Members 
 Posts: 3 
 Joined: 2007-09-11 
 Profile
 Posted : 2007-09-14 10:54:20
Thank you! That worked like a charm  

  Top 
  Rajib Bahar 
  
 Group: Members 
 Posts: 8 
 Joined: 2008-01-08 
 Profile
 Posted : 2008-02-27 03:54:04
Does this threading impact SSIS? In all of my trials, I noticed reading operations are a lot faster than inserts/updates. 

 
Rajib Bahar
http://www.rajib-bahar.com
http://www.icsql.com
http://www.youtube.com/icsql 
 
  Top 
  Tom 
  6c3c1_sdk-qodbc.gif
 Group: Administrator 
 Posts: 5510 
 Joined: 2006-02-17 
 Profile
 Posted : 2008-02-27 08:37:16
Yes, other developers have reported that they had to limit their DTS and SISS packages to a maximum of 4 connections. 

  Top 
  Piyush Varma 
  
 Group: Members 
 Posts: 66 
 Joined: 2006-04-06 
 Profile
 Posted : 2008-03-01 06:03:27
I will appreciate if somebody tells me how to implement following:

Your C# .NET Windows Console application needs to use a STA (single-threaded-apartment) threading model.

I am using QODBC Driver V 7 in a Windows Console VB.NET application with System.Net.ODBC namespace.

Thank you,

Piyush 

  Top 
  Tom 
  6c3c1_sdk-qodbc.gif
 Group: Administrator 
 Posts: 5510 
 Joined: 2006-02-17 
 Profile
 Posted : 2008-03-01 07:44:19

See the msdn .NET Framework Developer Center:  http://msdn2.microsoft.com/en-us/library/system.stathreadattribute.aspx

Note: ADODB works, but when you loop through the resultant recordset via Recordset.MoveNext(), an additional query is made through QODBC for each record.  These additional queries caused an additional 50 minutes of runtime for a 7000 invoice query.

The first function below demonstrates the ADODB method that took ~1 hour.  The second does the same thing with ODBC and takes less than a minute. 

[STAThread]
static void test1() {
    ADODB.Connection con = new ADODB.Connection();
    con.Open("DSN=SOQB;OLE DB Services=-2", "", "", -1);
    string invoiceSQL =
                "SELECT CustomerRefFullName, RefNumber, TxnDate, BalanceRemaining, AppliedAmount, Memo " +
                "FROM Invoice " +
                "WHERE TxnDate>{d'2006-04-02'}";
        ADODB.Recordset invoiceResult = new ADODB.Recordset();
        invoiceResult.Open(invoiceSQL, con, ADODB.CursorTypeEnum.adOpenStatic, ADODB.LockTypeEnum.adLockOptimistic, 0);
        while(!invoiceResult.EOF) {
                Console.WriteLine("Invoice #" + invoiceResult.Fields["RefNumber"].Value.ToString());
                invoiceResult.MoveNext();
        }
        con.Close();
}


[STAThread]
static void test2() {
        OdbcConnection con = new OdbcConnection("DSN=SOQB");
        con.Open();
        OdbcDataAdapter dAdapter = new OdbcDataAdapter(
                "SELECT CustomerRefFullName, RefNumber, TxnDate, BalanceRemaining, AppliedAmount, Memo " +
                "FROM Invoice " +
                "WHERE TxnDate>{d'2006-04-02'}", con);
        DataTable result = new DataTable();
        dAdapter.Fill(result);
        DataTableReader reader = new DataTableReader(result);
        while(reader.Read()){
                Console.WriteLine("Invoice #: " + reader.GetString(1));
        }
        con.Close();
}

 

  Top 
 New Topic 
 
 Post Reply 
[1]  

Jump to