Vbscript ADO question -- object not bubbling up from function corr

F

FrankG

Hi,

I'm having trouble working with an ADO object in a vbscript function.
Everything works fine until I try and put the offending code into a function,
then it looks like the object's type is lost, and I'm not able to use the
methods I want to use. Here is the code in question:

Function ExecSqlQuery(queryText)

Dim sqlConnection

Dim queryResult



set sqlConnection = CreateObject("ADODB.Connection")

sqlConnection.ConnectionString = "DSN=QA"

sqlConnection.Open



ExecSqlQuery= sqlConnection.Execute(queryText)

End Function



In order to call the function, I’m doing the following (for example):

set PaidInFullLoans=ExecSqlQuery(“select top 1 * from db.dbo.tableâ€)



The problem is that I can no longer use the “field†method, as in:

msgbox(PaidInFullLoans.field(“loanstatusâ€))




Before calling this from a function, everything worked fine. After doing
this from a funciton, however, for some weird reason I’m forced to use the
“item†method instead, and I’m also no longer able to use the EOF method, as
in “do until PaidInFullLoans.EOF". I'm still able to iterate through items,
as long as items are present, but the trouble begins when no records are
returned, and I have no way to detect that.



If I could come up with a way to count the number of objects in
PaidInFullLoans I could some sort of loop to iterate through the records, but
the count method is returning the number of columns for that objects, not the
number of rows. It’s very strange, and I’m almost ready to give up using this
function, as it works fine without it, it would just be cleaner with
functions.


When I'm debugging the code without the function, the object has many more
properties and methods available, but after it bubbles up from the function,
only "count" and "item" are available, and count doesn't even work right. Any
ideas?

Thanks,

Frank
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top