faqts : Computers : Programming : Languages : PHP : Database Backed Sites : ODBC

+ Search
Add Entry AlertManage Folder Edit Entry Add page to http://del.icio.us/
Did You Find This Entry Useful?

15 of 34 people (44%) answered Yes
Recently 4 of 10 people (40%) answered Yes

Entry

HOW do i make a simple DSN less connection with ODBC ACCESS drivers????

Sep 16th, 2000 23:53
John Lim, Pär Hedberg,


You have to use ADO to use DSN-less connections. 
An example with MS SQL 7, which you can adapt:
     $myDSN="PROVIDER=MSDASQL;DRIVER={SQL Server};"
	. "SERVER=flipper;DATABASE=ai;UID=sa;PWD=;"  ;
	$dbc = new COM("ADODB.Connection");
	$dbc->Provider = "MSDASQL";
	$dbc->Open($myDSN);
	$rs = $dbc->Execute("select * from products");
	$i = 0;
	while (!$rs->EOF) {
		$i += 1;
		$fld0 = $rs->Fields(0);
		$fld1 = $rs->Fields(1);
		$fld2 = $rs->Fields(2);
		print "$fld0->value $fld1->value $fld2->value<BR>";
		$rs->MoveNext();
	}
	$rs->Close();
See also the article: http://php.weblogs.com/odbc