PHP uses COM objects to access SQLServer and Access_PHP tutorials-php tutorials

Source: Internet
Author: User
PHP uses COM objects to Access SQLServer and Access. PHP4.0.6 or above can access COM and DCOM objects on the Win32 Platform. Use ASP to access SQLServer. Of course, you can also use mssql functions. For an ASPCoder, you can access COM and DCOM objects on the Win32 Platform at PHP4.0.6 or later. Use ASP to access SQLServer. Of course, you can also use mssql functions. If it is an ASP Coder, you will think the following code is very familiar and used to ---- no other, but PHP strong ~ _~ :
// Author: erquan
// Date: 2003-4-4
// City: Zhengzhou

$ DbConn = new COM ("ADODB. Connection") or die ("failed to create COM ");
$ ADO = "Provider = sqloledb; Data Source = localhost; Initial Catalog = myTest; User Id = sa; Password = sa ;";
// Access example: $ ADO = "DRIVER = {Microsoft Access Driver (*. mdb)}; DBQ =". realpath ("mydb. mdb ");
$ DbConn-> open ($ ADO );
// If ($ dbConn) echo "create conn OK ";
$ Rs = new COM ("ADODB. RecordSet") or die ("An error occurred while creating RS ");
Echo"
";
// If ($ rs) echo "create rs OK ";
$ SQL = "SELECT * FROM tb_bs ";
$ Rs-> open ($ SQL, $ dbConn, 1, 1 );

While (! $ Rs-> eof ){

Echo $ rs-> fields ["I _BsID"]-> value .":";
Echo $ rs-> fields ["vc_BsName"]-> value;
Echo"
";

$ Rs-> movenext ();
}

$ Rs-> Close;
$ Rs = null;

$ DbConn-> Close;
$ DbConn = null;
?>

How are you doing? For ASP Coder, if your BOSS suddenly receives a list of PHP projects, you don't have to worry about it. you can develop it smoothly at a moment ~

The stored procedure for accessing SQLServer is almost the same as that of ASP.

Access COM and DCOM objects on the Win32 Platform. Use ASP to access SQLServer. Of course, you can also use mssql functions. If it is an ASP Coder, you...

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.