Tutorials to .com

Tutorials to .com » Asp » Database » Using ASP to access a variety of commonly used type of database (2)

Using ASP to access a variety of commonly used type of database (2)

Print View , by: iSee ,Total views: 15 ,Word Count: 508 ,Date: Mon, 25 May 2009 Time: 4:11 AM

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 different (that is, the establishment of Connection as an example of method), once established finished Connection example, using Recordset object to access a number of ways to access data more or less the same, the following data for different types of preparation of the corresponding connection function, its prototype is as follows:

1) Function CreatMdbRecordset (database file name, file name or data sheets Select statement); the establishment of types of database objects Mdb

2) Function CreateSecuredMdbRecordset (database file name, file name or data sheets Select statement, password); the establishment of the MDB with a password type of database objects;

3) Function CreateDbfRecordset (directory name, DBF files or Select statement); the establishment of DBF types of database objects;

4) Function CreateDbcRecordset (DBC database file name, data tables or Select statement); the establishment of DBC types of database objects;

5) Function CreateExcelRecordset (XLS file name, Sheet name); the establishment of Excel types of database objects;

6) Function CreateSQLServerRecordset (computer name, user ID, user password, database name or to view data sheets or Select command); to establish the type of SQL Server database objects;


Third, the program list

'VBScript using the following procedure to prepare

1) the establishment of MdbRecordset object, Mdb database is a complete database, may contain a number of internal data tables in this function, Connection is the role of the database connection, Recordset's role is to open the data sheets.

Function CreateMdbRecordset (database files, and data sheets or Select statement)

Dim conn, Provider, DBPath

'Connection object the establishment of
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 the data table, parameter b for the Connection object
CreateMdbRecordset.Open "data table", conn, 2, 2

End Function


2) the establishment of Mdb password database with the Recordset object, the establishment of its way with the establishment of non-password Mdb database Recordset object is similar to a password only parameter, that is, with the database connection, it is important to give your password information.


ASP Database Related Articles


Can't Find What You're Looking For?


Rating: Not yet rated

Comments

No comments posted.