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