here code, trying open connection our database , using activex return data column in table , outputting text document. i'm getting error.
pulldata.vbs(41, 1) adodb.recordset: item cannot found in collection corresponding requested name or ordinal.
here code, ommiting sensitive information:
const forreading = 1 dim sserver dim slogin dim spwd dim sdb dim ocn dim ors sserver = "" slogin = "" spwd = "" sdb = "" set ocn = createobject( "adodb.connection" ) ' set ocn create object called adodb.connection set ors = createobject( "adodb.recordset" ) ' set ors create object called adodb.recordset ocn.connectionstring = "provider=sqloledb" & _ ";server=" & sserver & _ ";uid=" & slogin & _ ";pwd=" & spwd & _ ";database=" & sdb & " " ocn.connectiontimeout=600 ocn.open 'open connection server strselstring = "select callid dbo.calllog" 'this sql statement runs query on db ors.open strselstring,ocn 'this opens record set , has 2 parameters, strselstring , ocn if ors.eof 'if open record set @ end of file then... wscript.echo "there no records retrieve; check have correct record number." 'echo there no records retrieve. end if 'if there records loop through fields while not ors.eof ' while not open record set not end of file strfield = ors("tracker") if strfield <> "" 'if strfield doesn't equal "" set objfilesystem = wscript.createobject("scripting.filesystemobject") 'set objfilesystem create object scripting.filesystemobject set objoutputfile = objfilesystem.createtextfile("c:\test.txt", true) 'set objoutputfile create object objfilesystem.createtextfile strcomputer = ors 'strcomputer set read line wscript.echo strfield objoutputfile.writeline strfield &"|" objfilesystem.close objoutputfile.close end if ors.movenext ocn.close loop
you ask callid
column;
"select callid dbo.calllog"
but try read else:
strfield = ors("tracker")
so either select tracker
or read callid
.
you create/open file outside of loop.
Comments
Post a Comment