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 : Using a variable in SQL Select StatementSearch Forum

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

 New Topic 
 
 Post Reply 
[1]  
 Using a variable in SQL Select Statement 
 Author   Message 
  James 
  
 Group: Members 
 Posts: 3 
 Joined: 2008-07-05 
 Profile
 Posted : 2008-07-05 08:26:46

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

 

  Top 
  Tom 
  6c3c1_sdk-qodbc.gif
 Group: Administrator 
 Posts: 5510 
 Joined: 2006-02-17 
 Profile
 Posted : 2008-07-08 09:25:13

Try it with:

select_exp = "select * from InvoiceLine where RefNumber = "


IF .not. conn.execute(select_exp,vrefno)

 

  Top 
 New Topic 
 
 Post Reply 
[1]  

Jump to