I'm having some trouble using 2d arrays as created from SQL database recordsets using the DBGetRecordset UDF.
The actual database access isnt causing me a problem but pulling the data out of the array afterwards is. What am i doing wrong?
This UDF is supposed to return me a recordset that is a proper 2D array, but i instead seem to get a 1D array with each item consisting of multiple lines of data.
The code i'm attempting is as follows
Code:
$SQLQueryRS = "SELECT id,mac,name,locationid FROM computers where locationid is NULL"
$recordset = DBGetRecordset($objConn, $SQLQueryRS)
$retvalue = DBconnclose($objconn)
For $row=0 to Ubound($recordset,1)
? $recordset[$row,2]
Next
This gives me the error:
Code:
ERROR : expected ']'!
Script: M:\bin\sql\setup2.kix
Line : 157
Line 157 is ? $recordset[$row,2] - which should be displaying the second column in the current $row.
If i change my code to the following:
Code:
$SQLQueryRS = "SELECT id,mac,name,locationid FROM computers where locationid is NULL"
$recordset = DBGetRecordset($objConn, $SQLQueryRS)
$retvalue = DBconnclose($objconn)
For $row=0 to Ubound($recordset,1)
? $recordset[$row]
Next
I get the following output
Code:
1
0000E886E355
TOM-SSSSS
which has been correctly pulled out of my database and contains a complete row of data but on multiple lines. How do i access the items seperately?
(for reference the row in my database contains "1,0000E886E355,TOM-SSSSS,NULL" which is 1 row of data with 4 fields.)
Can anybody tell me what i am doing wrong here?
I get similar behavior and end up with multi-lined strings when i try and pull the complete list of section's out of an ini file using ReadProfileString like this
Code:
ReadProfileString ($machinesini,"","")
Thanks