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 : Error inserting Bill info?Search Forum

Forum Home > QODBC - ODBC Driver for QuickBooks > QODBC SQL Support Forum

 New Topic 
 
 Post Reply 
[1]  
 Error inserting Bill info? 
 Author   Message 
  Jerry 
  
 Group: Members 
 Posts: 5 
 Joined: 2006-04-15 
 Profile
 Posted : 2006-04-20 00:25:48
I am getting an error trying to create a bill.  The billexpenseline row completes ok, but the bill line fails.

SQL:
INSERT INTO BillExpenseLine (ExpenseLineAccountRefListID, ExpenseLineAmount, ExpenseLineMemo, ExpenseLineCustomerRefListID, FQSaveToCache) VALUES ('760000-929644518', 1.00, 'Expense Line Memo Test 1', '', 1)

INSERT INTO Bill (VendorRefListID, APAccountRefListID, TxnDate, RefNumber, TermsRefListID, DueDate, Memo) VALUES ('FD40000-1143654631','210001-930860374',{d'2006-04-17'}, 'POnumber', '', {d'2006-04-17'}, 'Expense Memo Test')

Error on 2nd insert:

[QODBC] Error: 3000 - The given object ID "" in the field "list id" is invalid.   Is this referring to the bill row list id?  Isn’t that auto generated?  If not, how do I know what to use?

Also, how do you trap errors from QODBC.  I had to run the inserts with DBQwikEdit to see the error returns.  My code below does not catch the error: 


expense="Direct Expense:Bulk Material - Install"   'qbname
set rse = CreateObject("ADODB.Recordset")
sqle = "select ListID from account where FullName = '" & expense & "'"
response.write sqle & "<br>"
rse.open sqle, DbConQB, 1
response.write rse("ListID") & " ID for Bulk Material - Install<br>"


vendor="Shemin Landscape Supply Company"
set rsv = CreateObject("ADODB.Recordset")
sqlv = "select ListID from vendor where CompanyName =  '" & vendor & "'"
response.write sqlv & "<br>"
rsv.open sqlv, DbConQB, 1
response.write rsv("ListID") & " ID for Shemin<br>"

 apaccount="Accounts Payable"
set rsa = CreateObject("ADODB.Recordset")
sqla = "select ListID from account where FullName =  '" & apaccount & "'"
response.write sqla & "<br>"
rsa.open sqla, DbConQB, 1
response.write rsa("ListID") & " ID for Accounts Payable<br>"

 sqliline = "INSERT INTO BillExpenseLine " _
 & "(ExpenseLineAccountRefListID, " _
 & "ExpenseLineAmount, " _
 & "ExpenseLineMemo, " _
 & "ExpenseLineCustomerRefListID, " _
 & "FQSaveToCache) " _
 & "VALUES ('" & rse("ListID") & "', 1.00, 'Expense Line Memo Test 1', '', 1)"

 response.write sqliline & "<br>"
err.clear
DbConQB.execute sqliline
if err.number then
 response.write err.Description
 response.end
end if

 sqlibill = "INSERT INTO Bill " _
 & "(VendorRefListID, " _
 & "APAccountRefListID, " _
 & "TxnDate, " _
 & "RefNumber, " _
 & "TermsRefListID, " _
 & "DueDate, " _
 & "Memo) VALUES ('" _
 & rsv("ListID") & "','" & rsa("ListID") & "',{d'2006-04-17'}, 'POnumber', '', {d'2006-04-17'}, 'Expense Memo Test')"
response.write sqlibill & "<br>"


DbConQB.execute sqlibill
if err.number then
 response.write err.Description
 response.end
end if

 

  Top 
  Tom 
  6c3c1_sdk-qodbc.gif
 Group: Administrator 
 Posts: 5510 
 Joined: 2006-02-17 
 Profile
 Posted : 2006-04-20 09:01:06

You must specifiy a value for ExpenseLineCustomerRefListID in your first statement.

This is found by doing something like:

select ListID, Fullname from customer where FullName like 'V%'

See: Empty BillExpenseLine Transaction?? for another example of the same problem

 

  Top 
  Jerry 
  
 Group: Members 
 Posts: 5 
 Joined: 2006-04-15 
 Profile
 Posted : 2006-04-20 23:48:52

Thanks Tom. 

I am entering these transactions from another system and we don't necessarily have the exact matching customer name that is in quickbooks.  Can I just put the customer name I have in the 'FullName' field even if I don't have the exact match or should I just put null in the RefListID field and put the customer name I have in the memo field?

Also, do you know how to trap errors coming back from QODBC in asp code?

 

  Top 
  Jerry 
  
 Group: Members 
 Posts: 5 
 Joined: 2006-04-15 
 Profile
 Posted : 2006-04-21 04:45:14

Tom,

1. Is the customer column a quickboods requirement or a qodbc requirement?  I don't have the actual QB customer information available and there are existing records in the QB tables with nulls in both of the customer fields.  Is there any way to insert the data without the customer fields?

2. How do I trap errors in asp code?

 

 

  Top 
  Tom 
  6c3c1_sdk-qodbc.gif
 Group: Administrator 
 Posts: 5510 
 Joined: 2006-02-17 
 Profile
 Posted : 2006-04-21 08:56:37

No, you can actually leave out ExpenseLineCustomerRefListID all together, you just can't say you are going to use it, and then try to insert a null. 

The following example also works:

INSERT INTO "BillExpenseLine" ("ExpenseLineAccountRefListID", "ExpenseLineAmount", "ExpenseLineMemo", "FQSaveToCache") VALUES ('120000-933270541', 436.07, 'Expense Line Memo Test 100', 1)

INSERT INTO "Bill" ("VendorRefListID", "APAccountRefListID", "TxnDate", "RefNumber", "TermsRefListID", "DueDate", "Memo") VALUES ('720000-1071512482', 'C0000-933270541', {d'2002-10-01'}, '100', '20000-933272658', {d'2002-10-31'}, 'Expense Memo Test')

Error trapping is a function of your programming interface, not QODBC. When debugging OLE DB Provider-specific ADO problems, you can dump the contents of the Errors collection to the immediate window with the following code:

For Each objError in objConn.Errors
            Debug.Print objError.Description
Next objError

 

  Top 
  Jerry 
  
 Group: Members 
 Posts: 5 
 Joined: 2006-04-15 
 Profile
 Posted : 2006-04-22 01:18:57
That did it!  The only issue I have left is that the insert to Bill hangs if there is an error.  I am able to create bills fine if everything is correct, but it any of the data in the inserts creates an error, the last insert never returns to my asp code.  I tested a select that generated an error and that worked fine.  I was able to access the error object and get the details of the error.  However, the insert to Bill never comes back.  Is there a config setting in the driver that might help?  What I did was delete one digit from the AP account list id value to generate the error.  Using an external tool, I see the error.  Using my asp code, the DbConQB.execute hangs.  Let me know what else I can try to fix this.  I really don't want to put code into production that could hang and force the user to close the browser and restart. 

  Top 
  Tom 
  6c3c1_sdk-qodbc.gif
 Group: Administrator 
 Posts: 5510 
 Joined: 2006-02-17 
 Profile
 Posted : 2006-04-22 23:36:55

The question now is how to we "trap" QODBC Insert errors? Well, after any QODBC insert, we will want to put the following lines:

If Err.number <> 0 then
  TrapError Err.description
End If

You will want to put this after all ADO calls that communicate directly with QODBC. This includes ConnectionObject.Open, ConnectionObject.Execute, and RecordsetObject.Open. Now, you may be wondering where the sub TrapError is defined: we're about to do that. Create a file called ErrorHandler.asp and put it in your /include or /scripts directory. In ErrorHandler.asp, we will have the following subs:

TrapError
ProcessErrors

Let's look at the code for ErrorHandler.asp:

<%
Dim strErrorMessage
Dim bolErrors

'Initialize variables
strErrorMessage = "" 'The error messages for tech. support
bolErrors = False 'Have we found any errors yet?

'Now our two subs
sub TrapError(strError)
  bolErrors = True 'We've found an error!

  strErrorMessage = strErrorMessage & strError & ", "
end sub

'If there are any errors, this function will show the error
sub ProcessErrors()
  if bolErrors then
    'Show the Error

    Response.Write "There has been a QODBC error. " & _
                    "At " & Now & " the following errors occurred on " & _
      "the page " & Request.ServerVariables("SCRIPT_NAME") & _
      ": " & _
                    chr(10) & chr(10) & strErrorMessage
  end if
end sub 

%>

That's all there is to it! Now, at the top of all your pages that you want to use the error handling routines, you'll need to include ErrorHandler.asp like so:

<!--#include virtual="/include/ErrorHandler.asp"-->

 

  Top 
  Jerry 
  
 Group: Members 
 Posts: 5 
 Joined: 2006-04-15 
 Profile
 Posted : 2006-04-23 12:07:09

My problem is that the second insert does not return to the script to allow me to test the error code.  I am testing with a 1 line bill.  The insert into BillExpenseLine works fine.  The insert to Bill hangs and never executes the next line of asp code after the DbConQB.Execute instruction.  If I insert completely valid data, the bill is created correctly and can be viewed in Quickbooks correctly.  If I change the AP Account List ID value to an invalid value, then the Bill insert hangs.  I put a response.end immediately after the DbConQB.Execute for the second insert to see if the insert or the error checking code was failing and the page never completed, thus the insert is hanging and not returning.  I open the connection with:

DbConQB.open("DSN=Quickbooks Data;OLE DB Services=-2")  as indicated in the documentation.  Is there any setting in IIS that can cause a bad insert to hang?  If I cause a deliberate error with a select, it returns as expected and the error values are set.  FYI, a failed select returns 0 in err.number, but the description and help context are set.

What can cause the insert to hang in the driver or how can I determine what the odbc driver is doing?  Is there any setting for a debug trace or log in the driver?

 

  Top 
  Tom 
  6c3c1_sdk-qodbc.gif
 Group: Administrator 
 Posts: 5510 
 Joined: 2006-02-17 
 Profile
 Posted : 2006-04-23 14:43:14
See: How do I turn on the trace log?  

  Top 
  Gerd 
  
 Group: Members 
 Posts: 28 
 Joined: 2008-12-09 
 Profile
 Posted : 2009-01-05 09:13:38

Tom, is the above error routine still valid for v9 and QB 2008 Prem?

I added the include as the first line in my sub but got already a compile error. Then I added the 2 subs of the include to my VBA. I also added the if err.number <> 0 right after executing the SQL but i got a system error instead of calling the error routines of your include.

I sure would like to get this working to catch all the SQL errors from QODBC.

 

  Top 
  Tom 
  6c3c1_sdk-qodbc.gif
 Group: Administrator 
 Posts: 5510 
 Joined: 2006-02-17 
 Profile
 Posted : 2009-01-05 11:17:51
The above example is only for VBScript within a ASP page. 

  Top 
  Gerd 
  
 Group: Members 
 Posts: 28 
 Joined: 2008-12-09 
 Profile
 Posted : 2009-01-05 11:22:10

Understood.

Thanks for your reply

 

  Top 
 New Topic 
 
 Post Reply 
[1]  

Jump to