I am using QODBC to select and also insert records in a QuickBooks company data file.
Using XBasic, I can connect and retrieve what I need. For example, the following pertinent code excerpt works as expected:
......
sqlStatement = <<%sql%
SELECT CompanyName, BillAddressCity, BillAddressState, BillAddressPostalCode FROM Customer WHERE CompanyName LIKE '5AM Partners%'
'%sql%
.....
Here, I am looking for a CompanyName that starts with 5AM Partners... from the Customer table. With the rest of the code not shown, it works fine.
But, I would like to pass as an argument to the SQL the CompanyName to search by. So, this is what I think should work:
dim args as sql::arguments
args.set("TestName","'5AM Partners%'")
sqlStatement = <<%sql%
SELECT CompanyName, BillAddressCity, BillAddressState, BillAddressPostalCode FROM Customer WHERE CompanyName LIKE :TestName
%sql%
This doesn't work - it returns an error dialog box saying: An argument value was reference in the SQL query, but no argument list was provided.
Would any one know the correct syntax for this?
Thanks a bunch!
UPDATE:
The following code does work:
temp1 = "'5AM Partners%'"
sqlStatement = "SELECT CompanyName, BillAddressCity FROM Customer WHERE CompanyName LIKE " + temp1
So, is it a problem with the <<%sql%.....%sql% being used with args.set(), perhaps at the end of the line?
Curious minds want to know...
Using XBasic, I can connect and retrieve what I need. For example, the following pertinent code excerpt works as expected:
......
sqlStatement = <<%sql%
SELECT CompanyName, BillAddressCity, BillAddressState, BillAddressPostalCode FROM Customer WHERE CompanyName LIKE '5AM Partners%'
'%sql%
.....
Here, I am looking for a CompanyName that starts with 5AM Partners... from the Customer table. With the rest of the code not shown, it works fine.
But, I would like to pass as an argument to the SQL the CompanyName to search by. So, this is what I think should work:
dim args as sql::arguments
args.set("TestName","'5AM Partners%'")
sqlStatement = <<%sql%
SELECT CompanyName, BillAddressCity, BillAddressState, BillAddressPostalCode FROM Customer WHERE CompanyName LIKE :TestName
%sql%
This doesn't work - it returns an error dialog box saying: An argument value was reference in the SQL query, but no argument list was provided.
Would any one know the correct syntax for this?
Thanks a bunch!
UPDATE:
The following code does work:
temp1 = "'5AM Partners%'"
sqlStatement = "SELECT CompanyName, BillAddressCity FROM Customer WHERE CompanyName LIKE " + temp1
So, is it a problem with the <<%sql%.....%sql% being used with args.set(), perhaps at the end of the line?
Curious minds want to know...
Comment