ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Quick Syntax Question (https://www.excelbanter.com/excel-programming/329648-quick-syntax-question.html)

UNOTech

Quick Syntax Question
 
Should i want a querytable that only returns one value to assign the returned
value to a string variable, how would i do that, the code as it looks now
is...

dim vReturnValue integer
Dim vSQLTable As New QueryTable
sqlstring = "DECLARE @ReturnValue INT exec FAKE_TEMP_TABLE 'InputParameter',
@OutputParam = @ReturnValue OUTPUT print @ReturnValue"
connstring = _
"ODBC;DSN=serverName;UID=;PWD=;Database=DBName "

'This is what I dont know how to do
vReturnValue = "returned value from datatable"

quartz[_2_]

Quick Syntax Question
 
The very nature of the QueryTable is that it is a spreadsheet object. I think
you need to either:

1) Return your data to a spreadsheet (even a temp sheet that can be deleted
after the query) and then copy your result into a variable;

OR

2) Return your information in a recordset, which will require that you alter
your DAO or ADO code somewhat. --- Can't help you there since your code
wasn't posted...

HTH

"UNOTech" wrote:

Should i want a querytable that only returns one value to assign the returned
value to a string variable, how would i do that, the code as it looks now
is...

dim vReturnValue integer
Dim vSQLTable As New QueryTable
sqlstring = "DECLARE @ReturnValue INT exec FAKE_TEMP_TABLE 'InputParameter',
@OutputParam = @ReturnValue OUTPUT print @ReturnValue"
connstring = _
"ODBC;DSN=serverName;UID=;PWD=;Database=DBName "

'This is what I dont know how to do
vReturnValue = "returned value from datatable"



All times are GMT +1. The time now is 07:49 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com