Use ASP to access various common type database (2)

Source: Internet
Author: User
Tags instance method mdb database connect table name
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.



Related Article

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.