Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Correct syntax for naming vbscript variable from sql query

Status
Not open for further replies.

kdjonesmtb2

Technical User
Nov 19, 2012
93
US
Hello

I ran the following sql query against a temporay table to create alias so that I can create vbscript variables from these aliases

I am getting a type mismatch

Thanks

Dim tSql

tSql = "select " &_
" htrio_row as htrio_row " &_
", htrio_cd as htrio_cd " &_
", htrio_qty as htrio_qty " &_
", qnxt_row as qnxt_row " &_
", qnxt_cd as qnxt_cd " &_
", qnxt_qty as qnxt_qty " &_
" from #cpt_variance "

conn.execute(tSql)


For icheck4 = 1 to 9

com_htrio_row = tSql("htrio_row")
com_htrio_cd = tSql("htrio_cd")
com_htrio_qty =tSql("htrio_qty")


print ("com_htrio_row")
print com_htrio_row
print ("com_htrio_cd")
print com_htrio_cd

Next


 
I think it is complaining about your use of tSQL as a recordset. Try
Code:
' Save the results in a recordset
set rs = conn.execute(tSql)


For icheck4 = 1 to 9

com_htrio_row = rs("htrio_row")
com_htrio_cd = rs("htrio_cd")
com_htrio_qty = rs("htrio_qty")

print ("com_htrio_row")
print com_htrio_row
print ("com_htrio_cd")
print com_htrio_cd

Next
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top