Use ASP to access various common type database (3)

Source: Internet
Author: User
Tags open dbf file mdb database table name
Data | database Function createsecuredmdbrecordset (database file name, datasheet name, or SELECT statement, password)

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")
' Connect to the database, note the following line with password parameters
Conn. Open Provider & dbpath& "Jet oledb:database password=" &assword
Set Createsecuredmdbrecordset = Server.CreateObject ("ADODB. Recordset ")
' Open data table, parameter two is connection object
Createsecuredmdbrecordset.open "datasheet name", Conn, 2, 2

End Function


3 DBF file is not a standard database file, only corresponds to a data table in the standard database file, so in order to use DBF file, put all DBF files in a directory, so that the directory name as the standard Data database table, each DBF file corresponds to the standard database data table. In the following function directory is the directory name of DBF,

Function createdbfrecordset (directory name, DBF filename, 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=DBF;"
DBPath = "sourcedb=" & Server.MapPath ("Directory Name")

' Invoke the Open method to open the database
Conn. Open Driver & sourcetype & DBPath

Set Createdbfrecordset = Server.CreateObject ("ADODB. Recordset ")
' Open DBF file, parameter two is connection object
Createdbfrecordset.open DBF filename or SELECT statement, Conn, 2, 2

End Function

4 the DBC database generated by FoxPro is similar to the MDB database, is a database contains several forms of data tables, so the access method for the DBC database is similar to 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;"



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.