Using ASP to access various common types of databases (2)

Source: Internet
Author: User
Microsoft Excel Driver Excel

Microsoft Visual FoxPro Driver Dbc

SQLOLEDB.1 SQL Server7.0

2. Connect to the database and open the data table
Different database Connection methods are different (that is, the method for establishing a Connection instance is different). Once a Connection instance is established, The Recordset object is used for data access, the following describes the corresponding connection functions for different data types. The prototype is as follows:
1) Function CreatMdbRecordset (database file name, data table file name or Select statement); create an Mdb Database object
2) Function CreateSecuredMdbRecordset (database file name, data table file name or Select statement, password); create a database object of the MDB type with a password;
3) Function CreateDbfRecordset (directory name, DBF file name or Select statement); create a DBF database object;
4) Function CreateDbcRecordset (database file name, data table name, or Select statement); create database objects of the DBC type;
5) Function CreateExcelRecordset (XLS file name, Sheet name); create an Excel-type database object;
6) Function CreateSQLServerRecordset (computer name, user ID, user password, database name data table or view table or Select command); create an SQL Server database object;
3. Program list
'The following programs are written in VBScript
1) create an MdbRecordset object. The Mdb Database is a complete database and may contain several data tables. In this function, Connection is used to connect to the database, and Recordset is used to open the data table.
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 the data table. Parameter 2 is the Connection object.
CreateMdbRecordset. Open "data table name", conn, 2, 2
End Function
2) create a Recordset object for the Mdb Database with a password. It is created in a similar way as The Recordset object for the Mdb Database without a password. It only has one more password parameter, that is, when connecting to the database, the password information must be provided.

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.