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

Source: Internet
Author: User
DBPath = "SourceDB =" & Server. MapPath ("DBC database file name ")
'Connect to the database
Conn. Open Driver & SourceType & DBPath
Set CreateDbcRecordset = Server. CreateObject ("ADODB. Recordset ")
'Open the data table. Parameter 2: Connection? Object
CreateDbcRecordset. Open "data table name or Select statement", conn, 2, 2
End Function
5) regard the XLS file (book) generated by Excel97 or Excel2000 as a database, and each worksheet (sheet) in it as a database table.
Function CreateExcelRecordset (XLS file name, 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 file name ")
'Call the Open method to Open the database
Conn. Open Driver & DBPath
Set CreateExcelRecordset = Server. CreateObject ("ADODB. Recordset ")
'Open Sheet. Parameter 2 is the Connection object. Because the Excel ODBC driver cannot open sheet directly with the 'sheet name, pay attention to the following select statement.
CreateExcelRecordset. Open "Select * From [" & sheet & "$]", conn, 2, 2
End Function
6) SQL Server is a Server-level database with strict usage requirements. You must enter the user name and password to use it.
Function CreateSQLServerRecordset (computer name, user ID, user password, database name data table or view table or Select command)
Dim Params, conn
Set CreatSQLServerConnection = Nothing
Set conn = Server. CreateObject ("ADODB. Connection ")
Params = "Provider = SQLOLEDB.1"
Params = Params & "; Data Source =" & Computer
Params = Params & "; User ID =" & UserID
Params = Params & "; Password =" & Password
Params = Params & ". Initial Catalog =" & database name
Conn open Paras
Set CreateSQLServerRecordset = Server. CreateObject ("ADODB. Recordset ")

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.