RE: ADO Com and PHP4

From: Date: Wed, 04 Oct 2000 17:28:04 +0000
Subject: RE: ADO Com and PHP4
References: 1  Groups: php.windows 
Request: Send a blank email to php-windows+get-2935@lists.php.net to get a copy of this message
Yes, the ADODB.Recordset object doesn't seem to work yet. Try the direct approach using only the ADODB.Connection object, like: $dbc = new COM("ADODB.Connection"); $dbc->Provider = "MSDASQL"; #ODBC connection $dbc->Open("your_DSN"); $rs = $dbc->Execute("SELECT * FROM nhrpch.dbo.tblOrganizations WHERE StreetState = 'TN'"; $i = 0; while (!$rs->EOF) { $i += 1; $fld0 = $rs->Fields("yourfieldname1"); $fld1 = $rs->Fields("yourfieldname2"); $fld5 = $rs->Fields(5); # here a field number print "$fld0->value $fld1->value $fld5->value<BR>"; $rs->MoveNext(); } $rs->Close(); This should work also with an SQLOLEDB connection, but I can't confirm it, as I'm not rich enough to own an m$sql db ;) Also check with John Lims' site for his ADODB database at: http://php.weblogs.com/ Good luck! Alain Message from Alain Samoun alain@samoun.com HEAR ME>> http://pagoo.com/signature/alain -----Original Message----- From: jimmy.daresta@lcca.com [mailto:jimmy.daresta@lcca.com] Sent: Wednesday, October 04, 2000 7:35 AM To: alain@samoun.com Subject: ADO Com and PHP4 Hi. I caught your article on PHP Builder about using com with PHP4. I decided after reading it that I would try it with ADO. Here is what I have for code; <? $test = new COM("ADODB.Connection"); $rstest = new COM("ADODB.Recordset"); $test->ConnectionString = "Provider=SQLOLEDB;UID=nhrpch;PWD=joeyg;Initial Catalog=nhrpch;Data Source=ESAU"; $test->Open; $SQL = "SELECT * FROM nhrpch.dbo.tblOrganizations WHERE StreetState = 'TN'"; $rstest->ActiveConnection = "DRIVER={SQL Server};UID=nhrpch;PWD=joeyg;Initial Catalog=nhrpch;Data Source=ESAU"; $rstest->Source = $SQL; $rstest->Open; echo $rstest->Fields(0); ?> All works fine until the Field retrieval. For some reason it hangs at the field retrieval. I have checked my db connect and so on and it all works fine from what I can tell. I just wondering if you have ever successfully called ADO from within PHP4. If so, is my syntax correct? My system btw is PHP 4.02, cgi method (the dll version caused problems for some reason) and MSSQL Server 7. Thanks! >From IP Address: 205.173.240.115 >From Browser: Mozilla/4.0 (compatible; MSIE 5.01; Windows NT)

« previous php.windows (#2935) next »