Unable to get SELECT SQL query result in VBScript

0

I'm using VBScript to access SQL Server and the configuration is ok as it works when inserting new values and even when changing the columns names.

However, now I want to get the name of the columns and I'am able to get the first record, but not the second and the third.

The format of the SQL query results are output in a single column with three rows.

Here's the documentation but I cannot get anything clear:(.

My code:

Function getColumnNames(tableName)
    Dim sql, rst
    rst = "result" 'result is a string array tag
    sql = "SELECT name FROM sys.columns WHERE object_id = OBJECT_ID('" & "precios"& "') ORDER BY column_id ASC"
    $DBExecute("sqlExpress", sql, rst)
    MsgBox $result(0)
    MsgBox $result(1)
    MsgBox $result(2)
End Function

$result(0) stores correctly the value while $result(1) and $result(2) are blank. I have tried several ways, as definining rst as:

rst = "result1, result2, result3" 'resultX are string tags
rst = "result(1), result(2), result(3)" 'result is a string array from 0 to 2

No one worked. Can anyone help me? Thanks.

Parents Reply Children
No Data