p2p.wrox.com Forums

Need to download code?

View our list of code downloads.


  Return to Index  

beginning_php thread: ADO Problems -- Tip


Message #1 by "Deepak Kumar Vasudevan" <deepak@c...> on Mon, 15 Apr 2002 08:41:58 +0530
This is a multi-part message in MIME format.

------=_NextPart_000_0025_01C1E459.67922DA0
Content-Type: text/plain;
	charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

Hi,

Instead of using direct COM instantitation, I would recommend the 
following, which will also ensure portability of the code: ADODB for PHP 
(which is I think in version 1.90 last week) from 
http://php.weblogs.com/


=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
Deepak Kumar Vasudevan, Software Engineer
CS Software Solutions Pvt. Ltd.
425 Pantheon Road, Egmore, Chennai 600 008, INDIA
Phones: +91 (44) 8311334 thru 38. Fax: +91 (44) 8311339
URL: www.cssolutionsinc.com
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D

> Subject: ADO problems
> From: "Peter Kaufman" <kaufman@l...>
> Date: Sun, 14 Apr 2002 08:27:40 +0700
> X-Message-Number: 2
>
> Hi Folks,
>
> I need some advice on the following:
>
> 1) Using this code, the recordset is apparently not opening as the
> attempt to print a field returns 'object' and, yes, the table 
definitely
> has records. I don't know why its not working. Trusted connection 
should
> not be a problem - it works in SQL Query Analyzer. The connection 
string
> is also shown below.
>
> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
>
> <html>
> <head>
> <title>Untitled</title>
> </head>
> <body>
> <?php
> $dbc =3D new com("ADODB.Connection");
> $dbc->open("DSN=3Dresume_be;");
> print($dbc->connectionstring);
> $strsql =3D "select * from tblContact";
> $rs =3D $dbc->execute("select * from tblContact");
> print $rs->recordcount
> ?>
> </body>
> </html>
>
> Provider=3DMSDASQL.1;Extended
> 
Properties=3D"DSN=3Dresume_be;UID=3D;WSID=3DATHELON;DATABASE=3Dresume_be;
Trusted_C
> onnection=3DYes"
>
> 2) I am working from the PHP Black Book, which has no info on 
connecting
> to anything but ODBC, MySQL and the like - not MS SQL or ADO. Can 
anyone
> point me to a tutorial on using ADO with PHP?
>
> Thanks a lot,
>
> Peter
>
>
>
> ----------------------------------------------------------------------



Message #2 by "Peter Kaufman" <kaufman@l...> on Mon, 15 Apr 2002 12:01:04 +0700
This is a multi-part message in MIME format.

------=_NextPart_000_000F_01C1E475.387B3630
Content-Type: text/plain;
	charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

Thanks, Deepak. I will check it out, but I would really like to know why
this is not working. Too many times I=92ve jumped around from tool to 
tool
only to hit problems with each one.

Peter

-----Original Message-----
From: Deepak Kumar Vasudevan [mailto:deepak@c...]
Sent: Monday, April 15, 2002 10:12 AM
To: beginning php
Cc: kaufman@l...
Subject: [beginning_php] ADO Problems -- Tip

Hi,

Instead of using direct COM instantitation, I would recommend the
following, which will also ensure portability of the code: ADODB for PHP
(which is I think in version 1.90 last week) from
<http://php.weblogs.com/> http://php.weblogs.com/


=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
Deepak Kumar Vasudevan <http://deepak.portland.co.uk/> , Software
Engineer
CS Software Solutions Pvt. Ltd.
425 Pantheon Road, Egmore, Chennai 600 008, INDIA
Phones: +91 (44) 8311334 thru 38. Fax: +91 (44) 8311339
URL:  <http://www.cssolutionsinc.com> www.cssolutionsinc.com
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D

> Subject: ADO problems
> From: "Peter Kaufman" < <mailto:kaufman@l...>
kaufman@l...>
> Date: Sun, 14 Apr 2002 08:27:40 +0700
> X-Message-Number: 2
>
> Hi Folks,
>
> I need some advice on the following:
>
> 1) Using this code, the recordset is apparently not opening as the
> attempt to print a field returns 'object' and, yes, the table
definitely
> has records. I don't know why its not working. Trusted connection
should
> not be a problem - it works in SQL Query Analyzer. The connection
string
> is also shown below.
>
> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
>
> <html>
> <head>
> <title>Untitled</title>
> </head>
> <body>
> <?php
> $dbc =3D new com("ADODB.Connection");
> $dbc->open("DSN=3Dresume_be;");
> print($dbc->connectionstring);
> $strsql =3D "select * from tblContact";
> $rs =3D $dbc->execute("select * from tblContact");
> print $rs->recordcount
> ?>
> </body>
> </html>
>
> Provider=3DMSDASQL.1;Extended
>
Properties=3D"DSN=3Dresume_be;UID=3D;WSID=3DATHELON;DATABASE=3Dresume_be;
Trusted_C
> onnection=3DYes"
>
> 2) I am working from the PHP Black Book, which has no info on
connecting
> to anything but ODBC, MySQL and the like - not MS SQL or ADO. Can
anyone
> point me to a tutorial on using ADO with PHP?
>
> Thanks a lot,
>
> Peter



Message #3 by "Peter Kaufman" <kaufman@l...> on Mon, 15 Apr 2002 16:20:52 +0700
Tried it with this code and an odbc dsn to Northwind:

<?php
include('adodb.inc.php');      
$conn =3D &ADONewConnection('access';
$conn->PConnect('northwind');  
$recordSet =3D &$conn->Execute('select * from products');
if (!$recordSet)
	print $conn->ErrorMsg();
else
while (!$recordSet->EOF) {
	print $recordSet->fields[0].' '.$recordSet->fields[1].'<BR>';
	$recordSet->MoveNext();
}
$recordSet->Close(); # optional
$conn->Close(); # optional
?>

Got an error:
Warning: SQL error: , SQL state 00000 in SQLConnect in
c:\inetpub\wwwroot\drivers\adodb-odbc.inc.php on line 113

Thanks,

Peter

-----Original Message-----
From: Deepak Kumar Vasudevan [mailto:deepak@c...]
Sent: Monday, April 15, 2002 10:12 AM
To: beginning php
Cc: kaufman@l...
Subject: [beginning_php] ADO Problems -- Tip

Hi,
=A0
Instead of using direct COM instantitation, I would recommend the
following, which will also ensure portability of the code: ADODB for PHP
(which is I think in version 1.90 last week) from
http://php.weblogs.com/
=A0
=A0
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
Deepak Kumar Vasudevan, Software Engineer
CS Software Solutions Pvt. Ltd.
425 Pantheon Road, Egmore, Chennai 600 008, INDIA
Phones: +91 (44) 8311334 thru 38. Fax: +91 (44) 8311339
URL: www.cssolutionsinc.com
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
=A0
> Subject: ADO problems
> From: "Peter Kaufman" <kaufman@l...>
> Date: Sun, 14 Apr 2002 08:27:40 +0700
> X-Message-Number: 2
>
> Hi Folks,
>
> I need some advice on the following:
>
> 1) Using this code, the recordset is apparently not opening as the
> attempt to print a field returns 'object' and, yes, the table
definitely
> has records. I don't know why its not working. Trusted connection
should
> not be a problem - it works in SQL Query Analyzer. The connection
string
> is also shown below.
>
> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
>
> <html>
> <head>
> <title>Untitled</title>
> </head>
> <body>
> <?php
> $dbc =3D new com("ADODB.Connection");
> $dbc->open("DSN=3Dresume_be;");
> print($dbc->connectionstring);
> $strsql =3D "select * from tblContact";
> $rs =3D $dbc->execute("select * from tblContact");
> print $rs->recordcount
> ?>
> </body>
> </html>
>
> Provider=3DMSDASQL.1;Extended
>
Properties=3D"DSN=3Dresume_be;UID=3D;WSID=3DATHELON;DATABASE=3Dresume_be;
Trusted_C
> onnection=3DYes"
>
> 2) I am working from the PHP Black Book, which has no info on
connecting
> to anything but ODBC, MySQL and the like - not MS SQL or ADO. Can
anyone
> point me to a tutorial on using ADO with PHP?
>
> Thanks a lot,
>
> Peter



  Return to Index