Use ASP to connect various databases

xiaoxiao2021-03-06  20

Use ASP to connect DBF, DBC, MDB, Excel, SQL Server type database: 1. ASP object Acquisition Database Method In ASP, you can access the object of the database to collect ADO (Active Data Objects), mainly containing three Object: Connection, RecordSet, CommandConnection: Responsible for opening or connecting data: responsible for accessing data table Command: Responsible for performing action query commands to Database 2, connecting Database Drivers to connect to each database can use drivers, or use data sources But I suggest that you use the driver because the use of the driver is very convenient, simple, and the use of the data source is more troublesome.

ODBC link

Suitable for database types

Link method

Access "Driver = {Microsoft Access Driver (*. MDB)}; dbq = *. MDB; UID = Admin; PWD = pass;" DBASE "driver = {Microsoft DBase Driver (*. dbf)}; driverid = 277; DBQ = ------------; "Oracle" driver = {microsoft odbc for oracle}; server = oraclesever.world; uid = admin; pwd = pass; "MSSQL Server" driver = {SQL Server} ; server = servername; database = dbname; uid = sa; pwd = pass; "ms text" driver = {microsoft text driver = {microsoft text driver (*. txt; * .csv)}; dbq = -----; extensions = ASC, csv, tab, txt; Persist securityInfo = false; "Visual Foxpro" Driver = {microsoft Visual Foxpro driver}; sourcetype = DBC;. sourceDB = * dbc; Exclusive = No; "MySQL" Driver = {mysql}; database = yourdatabase UID = username; PWD = YourPassword; Option = 16386; "

OLEDB link

Suitable database type

Link method

access "Provider = microsoft.jet.oledb.4.0; data source = your_database_path; user id = admin; password = pass;" Oracle "Provider = OraOLEDB.Oracle; data source = dbname; user id = admin; password = pass;" MS SQL Server "Provider = SQLOLEDB; data source = machinename; initial catalog = dbname; userid = sa; password = pass;" MS text "Provider = microsof.jet.oledb.4.0; data source = your_path; Extended Properties'text; FMT = DELIMITED '"

And we are using Access's database, here I suggest that you can connect the Access database to use the following method: DIM Conn Set CONN = Server.createObject ("AdoDb.Connection" Conn.Open = "provike = Microsoft.jet .oledb.4.0; "&" data source = "& server.mappath (" ../ db / bbs.mdb ")

Where ../db/bbs.mdb is your relative path for your data. If your database and the ASP file are in the same directory, you can write this way:

DIM Conn Set CONN = Server.createObject ("AdoDb.Connection") Conn.open = "Provider = Microsoft.jet.Oledb.4.0;" & "Data Source =" & Server.MAppath ("bbs.mdb")

Many beginners always have problems while encountering a database connection, but using the above driver As long as your database path is selected, it will not have problems.

转载请注明原文地址:https://www.9cbs.com/read-58996.html

New Post(0)