Inspired? No home

ByRef

We encountered a problem this week with VBScript. For some reason we couldn’t get ADO to begin a new transaction (BeginTrans()) using our global database function. After some twiddling we found the reason.

We had used this code:


Private c_db
c_db = null
DBStart(c_db)
DBBeginTrans(c_db)


all functions are using ByRef input arguments.

Because we set c_db to null, it had no memory reference and thus we had no object to update in the global DB functions.

So to work, we had to use this:


Private c_db
set c_db = server.createObject("ADODB.Connection")
DBStart(c_db)
DBBeginTrans(c_db)


We wanted the DBStart to handle the initialization of the ADO objects.

Written on 22 October 2004.
blog comments powered by Disqus