Multiple ADODB.Connection in vbScript -


i have array of database servers, , want execute same query of them in loop.
after first iteration following error :
- error number: 3704
- description: operation not allowed when object closed

the code i've implemented is:

        dim username      dim password      dim serverlist(4)      serverlist(0) = "serveraddress0"      serverlist(1) = "serveraddress1"      serverlist(2) = "serveraddress2"      serverlist(3) = "serveraddress3"       'username , password set      counter = 0 ubound(serverlist)-1        set connobj = createobject("adodb.connection")        set rsobj = createobject("adodb.recordset")        connstring = ..........        connobj.open connstring, username, password        'error comes here, in second iteration.         sqlscript = "select * ......"        rsobj.open sqlscript, connobj         while not rsobj.eof           'record set fetched.....           rsobj.movenext        loop         'current connection closed        rsobj.close        connobj.close       next 

note: first iteration code works perfectly. error come second iteration.

(0) disable "on error resume next" (if use it)

(1) ubound() returns last index, not size, change

for counter = 0 ubound(serverlist)-1 

to

for counter = 0 ubound(serverlist) 

(2) it's possible messed connection string, publish real code for

connstring = .......... 

(3) vbscript has until change

do while not rsobj.eof 

to

do until rsobj.eof 

(4) recordset named rsobj change

rsnice.movenext 

to

rsobj.movenext 

if did construct connection string properly, (4) cause of error.


Comments

Popular posts from this blog

android - Get AccessToken using signpost OAuth without opening a browser (Two legged Oauth) -

org.mockito.exceptions.misusing.InvalidUseOfMatchersException: mockito -

google shop client API returns 400 bad request error while adding an item -