kiffab Posted May 30, 2011 Posted May 30, 2011 Hi I have a query which should return multiple rows from a database. I want to write these to file. However, my code only seems to output a single row. How would i go about writing all the rows the query returns? Thanks ; Specify an ini file to write to $sIni = @ScriptDir & "\Documents.ini" ; Connect to the database $conn = ObjCreate( "ADODB.Connection" ) $DSN = "DRIVER={SQL Server};SERVER=server1;DATABASE=database1;UID=test1;PWD=test1;" $conn.Open($DSN) ;Create record set and run query $rs = ObjCreate("ADODB.RecordSet") $rs.Open("select filename+'.pdf' 'file' from test where id > 0", $conn) ; Write results to file Iniwrite($sIni, "Documents", "file", $rs.Fields("file").value) $conn.close Thanks in advance for any help
Zedna Posted May 30, 2011 Posted May 30, 2011 Searching this forum should give you answer too ; Specify an ini file to write to $sIni = @ScriptDir & "\Documents.ini" ; Connect to the database $conn = ObjCreate( "ADODB.Connection" ) $DSN = "DRIVER={SQL Server};SERVER=server1;DATABASE=database1;UID=test1;PWD=test1;" $conn.Open($DSN) ;Create record set and run query $rs = ObjCreate("ADODB.RecordSet") $rs.Open("select filename+'.pdf' 'file' from test where id > 0", $conn) If $RS.RecordCount Then While Not $RS.EOF Consolewrite("file: " & $rs.Fields("file").value & @CRLF) $RS.MoveNext WEnd EndIf $RS.Close $conn.close Resources UDF ResourcesEx UDF AutoIt Forum Search
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now