Use ASP to access various common type database (four)

Source: Internet
Author: User
Tags mdb database table name
Data | Database 4 The DBC database generated by FoxPro is similar to the MDB database, which is a database containing several data tables, so the access method for the DBC database is similar to that of the MDB database.

Function createdbcrecordset (DBC database file name, data table name, or SELECT statement)

Dim Conn,driver,sourcetype,dbpath

' Create a Connection object
Set conn = Server.CreateObject ("ADODB. Connection ")
Driver = "Driver={microsoft Visual FoxPro Driver};"
SourceType = "SOURCETYPE=DBC;"
DBPath = "sourcedb=" & Server.MapPath ("DBC database file name")
' Connect to the database
Conn. Open Driver & sourcetype & DBPath
Set Createdbcrecordset = Server.CreateObject ("ADODB. Recordset ")
' Open data table, parameter two is Connection object
Createdbcrecordset.open "Data table name or SELECT statement", Conn, 2, 2

End Function

5 The EXCEL97 or Excel2000 generated xls file (book) as a database, where each worksheet (sheet) as a database table.

Function createexcelrecordset (xls filename, sheet name)

Dim Conn. Driver,dbpath

' Create a Connection object
Set conn = Server.CreateObject ("ADODB. Connection ")
Driver = "Driver={microsoft Excel Driver (*.xls)};"
DBPath = "dbq=" & Server.MapPath ("XLS filename")

' Invoke the Open method to open the database
Conn. Open Driver & DBPath
Set Createexcelrecordset = Server.CreateObject ("ADODB. Recordset ")
' Open sheet, parameter two is connection object, because the Excel ODBC driver cannot open the sheet directly with the ' sheet name, so note the following SELECT statement
Createexcelrecordset.open "SELECT * FROM [" &sheet& "$]", Conn, 2, 2

End Function



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.