Hi
I have the following code which isn't working properly and I can't figure out what might be happening.
The problem is that only the first 3 columns will be produced on the web page.
If I make the following change
Then it shows 34 columns, which is correct, anyone got any ideas?
I have the following code which isn't working properly and I can't figure out what might be happening.
Code:
$myServer = "server";
$myUser = "user";
$myPass = "password";
$myDB = "db";
//create an instance of the ADO connection object
$conn = new COM ("ADODB.Connection") or die("Cannot start ADO");
//define connection string, specify database driver
$connStr = "PROVIDER=SQLOLEDB;SERVER=".$myServer.";UID=".$myUser.";PWD=".$myPass.";DATABASE=".$myDB;
$conn->open($connStr); //Open the connection to the database
//declare the SQL statement that will query the database
$query = "SELECT * FROM tablename WHERE CUSTOMER_NUMBER=10000000";
//execute the SQL statement and return records
$rs = $conn->execute($query);
$num_columns = $rs->Fields->Count();
//echo $num_columns . "<br>";
for ($i=0; $i < $num_columns; $i++) {
$fld[$i] = $rs->Fields($i);
echo $fld[$i];
}
echo "<table border=2>";
while (!$rs->EOF) //carry on looping through while there are records
{
echo "<tr>";
echo "<td align=right>" . $fld[0]. "</td>";
echo "<td align=right>" . $fld[1]. "</td>";
echo "<td align=right>" . $fld[2]. "</td>";
echo "<td align=right>" . $fld[3]. "</td>";
echo "<td align=right>" . $fld[4]. "</td>";
echo "<td align=right>" . $fld[9]. "</td>";
echo "</tr>";
$rs->MoveNext(); //move on to the next record
}
echo "</table>";
//close the connection and recordset objects freeing up resources
$rs->Close();
$conn->Close();
$rs = null;
$conn = null;
The problem is that only the first 3 columns will be produced on the web page.
If I make the following change
Code:
echo $num_columns . "<br>";