Re: Sql server -- trusted connection
| From: | Lowell Allen | Date: | Mon, 20 Jan 2003 21:16:55 +0000 |
| Subject: | Re: Sql server -- trusted connection | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-132288@lists.php.net to get a copy of this message | ||
> From: "Daniel Masson" <dmasson@imagine.com.co>
>
> I need help on this urgently.
>
> I need to connect to a ms sql server usgin windows autentication on a
> win 2000 box and IIS 5, i cant switch sql server to windows and sql
> authentication, .. I really need to know hot to connect.
I know very little about Windows, but I successfully made a COM connection
to MS-SQL recently. Here's sample code:
$db_connection = new COM("ADODB.Connection");
$db_connstr = "DRIVER={SQL
server};server=xdata;database=sampledb;uid=user;pwd=password;";
@$db_connection->open($db_connstr);
$select_sql = "SELECT FieldName1, FieldName2, FieldName3 FROM TableName
ORDER BY FieldName1";
@$rs = $db_connection->execute($select_sql);
if (!$rs) {
echo("<tr><td>Unable to make MS-SQL database
selection!</td></tr>\n" .
"</table>\n" .
"</body>\n" .
"</html>\n");
exit();
}
$rs_fld0 = $rs->Fields(0);
$rs_fld1 = $rs->Fields(1);
$rs_fld2 = $rs->Fields(2);
while (!$rs->EOF) {
echo("<tr bgcolor =
$color><td>$rs_fld0->value</td><td>$rs_fld1->value</td><td>$rs_fld2->value</
td></tr>\n");
$rs->MoveNext();
}
$rs->Close();
$db_connection->Close();
--
Lowell Allen