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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Type Mismatch with GetRows

Status
Not open for further replies.

JohnCR

Technical User
Jun 4, 2004
39
0
0
US
Hello,

I'm getting a "Type Mismatch" in this snippet of code. I'm hoping someone might be able to explain it ...

Dim rsTestlog
Dim arSta()
Dim arVer()

Set objFSO = CreateObject("Scripting.FileSystemObject")

sSQL = "SELECT Status, Version FROM TestLog"

Set connection = CreateObject("ADODB.Connection")
Set rsTestlog = CreateObject("ADODB.Recordset")
sConnString="DRIVER={Microsoft Access Driver (*.mdb)};" & _
"DBQ=" & "C:\data base" & "\test.mdb" & ";"
connection.open = sConnString
rsTestlog.Open sSQL, connection

arVer = rsTestlog.GetRows("Version") <-- Type Mismatch Here

wscript.echo arVer(0)

I'm merely trying to display the contents of arVer. Or, in this case the first instance of arVer.

Thank you in advance,

JohnCR

 
I think GetRows returns a two dimensional array. Thus when you try to do WSCript.Echo arVer(0), you are trying to display an array as a string. Try this:
WScript.Echo arVer(0,0)

[red]"... isn't sanity really just a one trick pony anyway?! I mean, all you get is one trick, rational thinking, but when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick[/red]
 
You have 3 problems:
1) arVer must be a Variant, not an Array
2) the ADO GetRows method expect 3 arguments: Rows,Start,Fields
3) GetRows return a variant which value is a bi-dimensional array
You may try something like this:
Dim arVer
arVer = rsTestlog.GetRows(,,"Version")
wscript.echo arVer(0,0)


Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top