I have uploaded a pdf file (varbinary(MAX)) in MSSQL running on my desktop via VS2010 (Ref) with just the UPDATE statement in the Ref.
The table has additional data associated with the pdf, like name, description, date.
Table in database:
Name | Description | Date | File |
DataSheet | Milling M/C | 2004-01-01 | <Binary data> |
Is it possible to display the table content in a web page as
Name | Description | Date | File |`
DataSheet | Milling M/C | 2004-01-01 | (link to the pdf) |
or
Name | Description | Date | File |
DataSheet | Milling M/C | 2004-01-01 | (an icon of pdf) |
using PHP so that user can click the link/file to view it. There will be lot of rows, I just gave 1 row for example.
Please let me know if I am not clear, thanks in advance.
PS: I did create some images but was not able to post them, sorry about the format
What I have done so far
I am using 'Connect without a DSN (using a connection string)' from here
$conn = new COM ("ADODB.Connection") or die("Cannot start ADO");
$connStr = "PROVIDER=SQLOLEDB;SERVER=".$myServer.";UID=".$myUser.";PWD=".$myPass.";DATABASE=".$myDB;
$conn->open($connStr);
$query = "select * from Table";
$rs = $conn->execute($query);
$num_columns = $rs->Fields->Count();
for ($i=0; $i < $num_columns; $i++) {
$fld[$i] = $rs->Fields($i);
}
while (!$rs->EOF)
{
for ($i=0; $i < $num_columns; $i++) {
echo $fld[$i]->value;
}
$rs->MoveNext();
}
The result I am getting is garbage for binary data.
DataSheet | Milling M/C | 2004-01-01 | some_garbage |