I. php merge MSSQL
$ Dbhost = '';
$ Dbuser = ''; // your MSSQL User Name
$ Dbpass = ''; // your MSSQL Password
$ Dbname = ''; // your MSSQL database name
$ Connect = odbc_connect ("driver = {SQL Server}; server = $ dbhost; database = $ dbname", "$ dbuser", "$ dbpass ");
$ SQL = "select * from content ";
$ Exec = odbc_exec ($ connect, $ SQL );
While ($ ROW = (odbc_fetch_array ($ Exec )))
{
$ Row ['id'] // retrieve the field value
...
}
2. php login access
$ Db = $ _ server ['document _ root']. "/php_access/include/# mydb. mdb "; // it is best to use $ _ server ['document _ root'] to retrieve the path.
$ Conn = new COM ('ADODB. connection') or die ('can not start Active X Data objects ');
$ Conn-> open ("driver = {Microsoft Access Driver (*. mdb)}; DBQ = $ DB ");
$ Rs = $ Conn-> execute ('select * from contents order by id desc ');
While (! $ RS-> EOF)
{
Echo $ RS-> fields ['name']-> value;
$ RS-> movenext ();
}
/* Release resources */
$ RS-> close ();
$ Conn-> close ();
$ Rs = NULL;
$ Conn = NULL;
Fatal error: uncaught exception 'com _ exception' with message' <B> Source: </B> Microsoft ole db provider for ODBC drivers <br/> <B> description: </B> [Microsoft] [ODBC Microsoft Access driver] disk or network error.'
(* The above problem occurs on XP, but it can run normally on 2003. It may be related to the ODBC configuration of the computer )???????
3. js connector access data statistics
Scengine. JS File
// Database-like connection pool
Function scdbpool (){
Try {
This. Con = new activexobject ("ADODB. Connection ");
This. Con. provider = "Microsoft. Jet. oledb.4.0 ";
This. rs = new activexobject ("ADODB. recordset ");
} Catch (e ){
This. Con = NULL;
This. rs = NULL;
}
This. filepath = NULL;
This. dbpath = NULL;
};
// Set the relative path of the database file (locate the file) and the database name
Scdbpool. Prototype. setdb = function (dbpath ){
This. dbpath = dbpath;
};
// Set the database location file. This step can be included in the connection class. Here, the database is written to facilitate the use of any name.
Scdbpool. Prototype. setdbpathposition = function (urlfile ){
VaR filepath = location. href. substring (0, location. href. indexof (urlfile ));
This. dbpath = (this. dbpath = NULL | this. dbpath = "")? "/Calendar. mdb": This. dbpath;
VaR Path = filepath + this. dbpath;
// Remove the "files: //" string before the path
This. filepath = path. substring (8 );
};
// Establish a connection with the database
Scdbpool. Prototype. Connect = function (){
This. filepath = "C: \ Documents and Settings \ Zhen. Wang \ Desktop \ js_calendar \ calendar. mdb"; // access path
This. Con. connectionstring = "Data Source =" + this. filepath;
// Alert (this. Con. connectionstring );
This. Con. open;
};
// Execute the database statement and return the result set
Scdbpool.prototype.exe cutequery = function (SQL ){
This. Rs. Open (SQL, this. Con );
};
// No result set is returned when database statements are executed.
Scdbpool.prototype.exe cute = function (SQL ){
This.con.exe cute (SQL );
};
// Close the result set
Scdbpool. Prototype. rsclose = function (){
This. Rs. Close ();
This. rs = NULL;
};
// Close the data connection
Scdbpool. Prototype. conclose = function (){
This. Con. Close ();
This. Con = NULL;
};
Usage:
<HTML>
<Head> <title> DDD </title>
<Script language = "JavaScript" src = "scengine. js"> </SCRIPT>
</Head>
<Body>
<Script language = "JavaScript">
VaR DB = new scdbpool ();
DB. setdb ("calendar. mdb ");
DB. Connect ();
VaR SQL = "insert into ctime (week) values ('ddd ')";
Db.exe cute (SQL );
/*
Db.exe cutequery (SQL );
While (! DB. Rs. EOF ){
VaR CNT = dB. Rs. Fields ("data ");
Document. Write (CNT );
DB. Rs. movenext;
}
*/
DB. rsclose ();
DB. conclose ();
</SCRIPT>
</Body>