note 24549 added to ref.com

From: Date: Wed, 21 Aug 2002 07:30:38 +0000
Subject: note 24549 added to ref.com
Groups: php.notes 
Request: Send a blank email to php-notes+get-35293@lists.php.net to get a copy of this message
This is a sample to make a parametrized query using ADO via COM, this sample was used with Foxpro but will work's with most ADO complient databases. This was tested on IIS with WIN XP pro. <? // Create the main connection $dbc = new COM("ADODB.Connection") or die ("connection create fail"); $dbc->Provider = "MSDASQL"; $dbc->Open("FoxDatabase"); // Creates a temporary record set $RSet = new COM("ADODB.Recordset"); // Create one ADO command $cm = new COM("ADODB.Command"); $cm->Activeconnection = $dbc; // the ? inside values will be the parameters $par01 and $par02 $cm->CommandText = "Insert Into testtable ( mycharfield,mymemofield) VALUES (?,?)" ; $cm->Prepared = TRUE; // Creates and append 2 parameters $par01 = $cm->CreateParameter('ppar01',129,1,50,'ABCDEFGHIKL'); $cm->Parameters->Append($par01); $par02 = $cm->CreateParameter('ppar01',129,1,50,'123456789012346789'); $cm->Parameters->Append($par02); // Call 10 times the exec comand to show 10 different queries for ($i = 1; $i <= 10; $i++) { $par01->Value = 'Count '.$i; $par02->Value = 'Passing here'.$i.' times'; $RSet = $cm->Execute; } $RSet = $dbc->Execute("select * from testtable"); while (!$RSet->EOF){ echo $RSet->fields["mycharfield"]->value.' ' ; echo $RSet->fields["mymemofield"]->value ; echo '<BR>'; $RSet->movenext(); } $RSet->close; $dbc->close; $cm->close; $RSet = null; $dbc = null; $cm = null; ?> -- http://www.php.net/manual/en/ref.com.php http://master.php.net/manage/user-notes.php?action=edit+24549 http://master.php.net/manage/user-notes.php?action=delete+24549 http://master.php.net/manage/user-notes.php?action=reject+24549

« previous php.notes (#35293) next »