I'm trying to build an SQL Select statement that will return the value of the "Txnid" field in the InvoiceLine table in QuickBooks when filtered by the value in the "Refnumber" field. When I use the actual value of the data in the "Refnumber" field...EX: 1001, the following code works perfectly. However I need the code to work when a variable "Vrefno" is used in place of the actual value and have not been able to figure out how to replace the actual value '1001' with the variable.
BEGIN SAMPLE CODE:
DIM conn as SQL::Connection dim flagResult as l flagResult = conn.open("::Name::QB_link") IF flagResult = .f. THEN ui_msg_box("Error","Could not connect to database. Error reported was: " + crlf() + conn.CallResult.text) end END IF
'Specify that we are using Portable SQL syntax conn.PortableSQLEnabled = .t.
Dim shared Vrefno as C Vrefno = 1001 'Dim a SQL arguments object, create arguments and set their values DIM args as sql::arguments args.set("RefNumber",Vrefno)
dim rs as SQL::ResultSet dim connString as C dim select_exp as C connString = "{A5API=QuickBooks,FileName='C:\Program Files\Intuit\QuickBooks Enterprise Solutions 8.0\QB_Test_Copy\Test..QBW',UserName='Admin',Password='ôèéåæó'}" select_exp = "select * from InvoiceLine where RefNumber = '1001'" HOW DO REPLACE THE '1001' WITH THE VARIABLE 'VREFNO'??
IF .not. conn.open(connString) ui_msg_box("Error", conn.CallResult.text) end END IF IF .not. conn.execute(select_exp,args) ui_msg_box("Error", conn.CallResult.text) conn.close() end END IF rs = conn.ResultSet rs.NextRow() ui_msg_box("SQL::ResultSet::Data()with column number", rs.data(1)) conn.close()
END SAMPLE CODE
Thanks
James |