Hi

I've written a simple routine to upload into Quickbooks via the QODBC.com
link. What I'm finding is periodically some records are not getting written
into quickbooks. I can run the insert statements manually and they work so I
suspect it has something to do with firing the inserts one after the other.

Does SQLExec need a delay loop to wait until it has finished executing each
insert command?

This is the code for QB. It looks to see if the customer record is already
on file, inserts if not then checks again to see if went through, finally it
adds a child record for the job card.

Regards
Graham


Select emails
Go Top
nH=SQLConnect("QuickBooks Data")
If nH<=0
        Wait Window "Unable to connect to Quickbooks"
Else
        N=1
        Scan For emails.f_imported="No"
                =SQLEXEC(nH,"Select * from customer where
name='"+Strtran(Proper(Alltrim(emails.f_forename)+"
"+Alltrim(emails.f_surname)),"'","''")+"'","MyCust")
                If Reccount("MyCust")=0
** Need to add the customer record
                        cSQL="Insert into customer
(Name,BillAddressAddr1,BillAddressAddr2,BillAddressAddr3,BillAddressAddr4,Bi
llAddressCity,email,isActive,CompanyName) values("
                        
cSQL=cSQL+"'"+Strtran(Proper(Alltrim(emails.f_forename)+"
"+Alltrim(emails.f_surname)),"'","''")+"',"
                        cSQL=cSQL+"'"+Rtrim(m.add1)+"',"
                        cSQL=cSQL+"'"+Rtrim(m.add2)+"',"
                        cSQL=cSQL+"'"+Rtrim(m.add3)+"',"
                        cSQL=cSQL+"'"+Rtrim(m.add4)+"',"
                        cSQL=cSQL+"'"+Rtrim(m.add5)+"',"
                        cSQL=cSQL+"'"+Rtrim(emails.f_email)+"',"
                        cSQL=cSQL+"1,"
                        
cSQL=cSQL+"'"+Strtran(Proper(Alltrim(emails.f_forename)+"
"+Alltrim(emails.f_surname)),"'","''")+"'"
                        cSQL=cSQL+")"
                        oSecurity.recordEvent("SQL","",cSQL)
                        =SQLEXEC(nH,cSQL)
                        =Sqlcommit(nH)

                Endif
                cSQL="Select * from customer where name like
'"+Proper(Alltrim(emails.f_forename)+" "+Alltrim(emails.f_surname))+"%'"
                =SQLEXEC(nH,cSQL,"MyCust")
                If Reccount("MyCust")>0
**name,parentreflistid,parentreffullname,companyname,jobdesc
                        m.faultinfo="Fault Desc here"
                        cSQL="Insert into customer
(name,notes,jobstatus,parentreflistid,parentreffullname,jobdesc) values("
                        cSQL=cSQL+"'Job:"+Alltrim(Str(emails.f_jobno))+" -
"+Strtran(Proper(Alltrim(emails.f_make)+"
"+Alltrim(emails.f_model)),"'","''")+" ("+Strtran(Time(),":","")+")',"
                        cSQL=cSQL+"'"+Rtrim(Strtran(m.faultinfo,"'","''"))+"',"
                        cSQL=cSQL+"'Pending',"
                        cSQL=cSQL+"'"+Rtrim(MyCust.listid)+"',"
                        cSQL=cSQL+"'"+Rtrim(MyCust.parentreffullname)+"',"
                        cSQL=cSQL+"'"+Rtrim(MyCust.companyname)+"',"
                        
cSQL=cSQL+"'"+Rtrim(Proper(Strtran(Alltrim(emails.f_make)+"
"+Alltrim(emails.f_model),"'","''")))+"'"
                        cSQL=cSQL+")"
                        =SQLEXEC(nH,cSQL)
                        =Sqlcommit(nH)

                Endif
                N=N+1
                Select emails
                Replace f_imported With "Yes"
                =Tableupdate()
        Endscan
        =SQLDISCONNECT(nH)
Endif



_______________________________________________
Post Messages to: ProFox@leafe.com
Subscription Maintenance: http://leafe.com/mailman/listinfo/profox
OT-free version of this list: http://leafe.com/mailman/listinfo/profoxtech
Searchable Archive: http://leafe.com/archives/search/profox
This message: http://leafe.com/archives/byMID/profox/[EMAIL PROTECTED]
** All postings, unless explicitly stated otherwise, are the opinions of the 
author, and do not constitute legal or medical advice. This statement is added 
to the messages for those lawyers who are too stupid to see the obvious.

Reply via email to