The following are several database connection programs collected at work and can be used to test the database. Access2003 Connection Program (asp): % dimdbpath, connstr, conndbpath # bjbaidu. mdbconnstrDRIVERMicrosoftAccessDriver (*. mdb); DBQserver. mappath (dbpath) SetconnServer. CreateObject (
The following are several database connection programs collected at work and can be used to test the database. Access 2003 Connection Program (asp): % dim dbpath, connstr, conn dbpath = "# bjbaidu. mdb "connstr =" DRIVER = Microsoft Access Driver (*. mdb); DBQ = "server. mappath (dbpath) Set conn = Server. createObject (
The following are several database connection programs collected at work and can be used to test the database.Access 2003 Connection Program (asp ):<%
Dim dbpath, connstr, conn
Dbpath = "# bjbaidu. mdb"
Connstr = "DRIVER = Microsoft Access Driver (*. mdb); DBQ =" & server. mappath (dbpath)
Set conn = Server. CreateObject ("ADODB. Connection ")
Conn. Open connstr
%>Access 2007 Connection Program (asp ):<%
Dim dbpath, connstr, conn
Dbpath = "123. accdb"
Connstr = "DRIVER = Microsoft Access Driver (*. mdb, *. accdb); DBQ =" & server. mappath (dbpath)
Set conn = Server. CreateObject ("ADODB. Connection ")
Conn. Open connstr
%>Access Connection (php ): /*
* Create An ADO connection
*/
$ Conn = @ new COM ("ADODB. Connection") or die ("ADO Connection faild .");
$ Connstr = "DRIVER = {Microsoft Access Driver (*. mdb)}; DBQ =". realpath ("# bjbaidu. mdb ");
$ Conn-> open ($ connstr );
/*
* Create a record set
*/
$ Rs = @ new COM ("ADODB. RecordSet ");
$ Rs-> open ("select * from bj_link", $ conn, 1, 3 );
/*
* Read data cyclically
*/
While (! $ Rs-> eof ){
Echo $ rs-> fields ['title']-> Value;
Echo"
";
$ Rs-> movenext (); // move the record set pointer down
}
$ Rs-> close ();
?>Mysql connection (php ): Header ("Content-type: text/html; charset = UTF-8 ");
$ Mysql_server_name = "222.76.214.216"; // database server name
$ Mysql_username = "sunhillscn"; // username used to connect to the database
$ Mysql_password = "123"; // connection password
$ Mysql_database = "sunhillscn"; // Database Name
// Connect to the database
$ Conn = mysql_connect ($ mysql_server_name, $ mysql_username,
$ Mysql_password );
// SQL statement used to extract information from the table
$ Strsql = "select * from cnscms_article limit 5 ";
// Execute SQL query
$ Result = mysql_db_query ($ mysql_database, $ strsql, $ conn );
// Obtain the query result
$ Row = mysql_fetch_row ($ result );
Echo '';
Echo'
{
Echo'
{
Echo'
'; // Display the field nameEcho "\ n
\ N ";For ($ I = 0; $ I
'. Mysql_field_name ($ result, $ I ); Echo" | \ N ";}Echo"
\ N ";// Locate the first recordMysql_data_seek ($ result, 0 );// Retrieve records cyclicallyWhile ($ row = mysql_fetch_row ($ result )){Echo"
\ N ";For ($ I = 0; $ I
'; Echo "$ row [$ I]"; Echo' | ';}Echo"
\ N ";} Echo"
\ N ";
Echo "";
// Release resources
Mysql_free_result ($ result );
// Close the connection
Mysql_close ();
?> For more database connection code, visit http://www.connectionstrings.com /.