Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

accessing a database through OLEDB using COM functions?

Status
Not open for further replies.

Khaldryck

Programmer
Oct 26, 2000
13
BE
i have been assigned a new way of working, but have no idea how to do it.
i was accessing a DB using ODBC, but now i must do it using the COM functions to access it through OLEDB.
anyone can help me ? Khaldryck
Programmer at the University of Brussel (Belgium)
 
khaldryck,

At the bottom is a sample of how you can use COM with PHP and ADO (OLEDB and ODBC) using ADODB. It might be a little difficult for you to get any information regarding OLEDB since it is less supported, but more with ODBC (remember we're talking COM connectivity here). In any case, this just might get you on the right track.

Here is a good place to download an ADODB library for you to use with your PHP applications:

//for windows
//for unix

This class library currently supports MySQL, PostgreSQL, Interbase, Oracle, MS SQL 7, Foxpro, Access, ADO, Sybase and generic ODBC. The Sybase and PostgreSQL drivers are community contributions. We hope more people will contribute drivers to support more databases.

Code:
<?
	$dbc = new COM(&quot;ADODB.Connection&quot;);
	$dbc->Provider = &quot;MSDASQL&quot;;
	$dbc->Open(&quot;nwind&quot;);
	$rs = $dbc->Execute(&quot;select * from products&quot;);
	$i = 0;
	$fld0 = $rs->Fields(0);
	$fld1 = $rs->Fields(1);
	$fld2 = $rs->Fields(2);
	while (!$rs->EOF) {
		$i += 1;
		print &quot;$fld0->value $fld1->value $fld2->value<BR>&quot;;
		$rs->MoveNext(); /*updates fld0, fld1, fld2 !*/
	}
	$rs->Close();
?>

Does this help?

Good Luck!
Chad ICQ: 54380631
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top