Data | database uses ASP to connect DBF, DBC, MDB, Excel, SQL Server database methods:
ASP Object Access database method
In ASP, the object that accesses a database is called ADO (Active Data Objects), contains three kinds of objects mainly: Connection, Recordset, Command
Connection: Responsible for opening or connecting data
Recordset: Responsible for accessing data tables
Command: Responsible for performing action query commands on the database
Two, the connection each database driver
You can use a driver or a data source to connect to each database, but I recommend that you use a driver because it's easy and easy to use, and it's cumbersome to use a data source.
ODBC links
Ways to link database types
Access "Driver={microsoft access Driver (*.mdb)};d bq=*.mdb;uid=admin;pwd=pass;"
DBase "Driver={microsoft dBase Driver (*.dbf)};d riverid=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)};d bq=-----; extensions=asc,csv,tab,txt; Persist Securityinfo=false; "
Visual Foxpro "Driver={microsoft visual Foxpro Driver};sourcetype=dbc;sourcedb=*.dbc; Exclusive=no; "
MySQL "Driver={mysql};d atabase=yourdatabase;uid=username;pwd=yourpassword;option=16386;"
OLE DB Links
The appropriate way to link database types
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 generally use Access database more, here I recommend that you connect to an Access database using the following methods:
Dim conn
Set conn = Server.CreateObject ("Adodb.connection")
Conn.Open = "Provider=Microsoft.Jet.OLEDB.4.0" & "Data Source =" & Server.MapPath (". /db/bbs.mdb ")
Which.. /db/bbs.mdb is the relative path of your database store! If your database and ASP files are in the same directory, you can just write this:
Dim conn
Set conn = Server.CreateObject ("Adodb.connection")
Conn.Open = "Provider=Microsoft.Jet.OLEDB.4.0" & "Data Source =" & Server.MapPath ("Bbs.mdb")
There are many beginners who have problems when they encounter a database connection, but using the driver above will not be a problem as long as your database path is selected.