Using ASP to connect DBF, DBC, MDB, Excel, SQL Server database approach:
1. ASP database object access method
In ASP, to access the database objects referred to ADO (Active Data Objects) which mainly contains three kinds of objects: Connection, Recordset, Command.
Connection: connection data for opening
Recordset: for access data table
Command: for implementation of action on the database query command
2. Connecting database driver
The database can be connected by the driver, or can also use the data source. I think that use the driver is easier than data source.
3. ODBC Link:
Database type; Link mode
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(*.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;"
4. OLEDB Link
Database type; Link mode
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'"
5. More about Access database
Generally we use Access databases, I think we can connect Access database using the following method:
dim conn
set conn = server.createobject("adodb.connection")
conn.open = "provider=microsoft.jet.oledb.4.0;" & "data source = " & server.mappath("../db/bbs.mdb")
Including .. / db / bbs.mdb is stored in the relative path! If the database and ASP files in the same directory, need only to write on:
dim conn
set conn = server.createobject("adodb.connection")
conn.open = "provider=microsoft.jet.oledb.4.0;" & "data source = " & server.mappath("bbs.mdb")
Once chosen correct driver and path of the database, database connection will not be a problem.
No comments:
Post a Comment