Data | database Microsoft Excel Driver Excel
Microsoft Visual FoxPro Driver DBC
Sqloledb.1 SQL Server7.0
Second, connect the database and open the data table
Different database connection methods are not the same (that is, the establishment of connection instance method is not the same), once the establishment of the connection instance, the use of Recordset objects to access data from the same method, the following for different types of data, write the corresponding connection function, The prototype is as follows:
1 Function creatmdbrecordset (database file name, datasheet file name, or SELECT statement); database object of MDB type
2 Function createsecuredmdbrecordset (database file name, datasheet file name or SELECT statement, password); Set up a database object with a password MDB type;
3 Function createdbfrecordset (directory name, DBF filename or SELECT statement), and establish DBF type database object;
4 Function createdbcrecordset (DBC database file name, data table name or SELECT statement), establish DBC type of database object;
5 Function createexcelrecordset (xls filename, sheet name), build database object of Excel type;
6 Function createsqlserverrecordset (computer name, user ID, user password, database name datasheet or view table or select instruction); Build SQL Server type database object;
Iii. List of procedures
' The following programs are written in VBScript
1 The establishment of Mdbrecordset object, MDB database is a complete database, the internal may contain several data tables, in this function, the role of connection is to connect the database, the role of the recordset is to open the datasheet.
Function createmdbrecordset (database file name, data table name, or SELECT statement)
Dim Conn,provider,dbpath
' Create a Connection object
Set conn = Server.CreateObject ("ADODB. Connection ")
Provider = "Provider=Microsoft.Jet.OLEDB.4.0;"
DBPath = "Data source=" & Server.MapPath ("Database file name")
' Open the Database
Conn. Open Provider & DBPath
Set Createmdbrecordset = Server.CreateObject ("ADODB. Recordset ")
' Open data table, parameter two is connection object
Createmdbrecordset.open "datasheet name", Conn, 2, 2
End Function
2 Create a Recordset object with a password MDB database, which is built like a Recordset object with an MDB database without a password, but one more password parameter, that is, the password information must be given when connecting to the database.