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;"
OLEDB链接
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'"
在Asp中连接Access的数据库相关代码可以写为:
Dim db,conn,connstr
db="data/hezepolice.mdb"
Set conn = Server.CreateObject("ADODB.Connection")
connstr="DBQ="+server.mappath("db")+";DefaultDir=;DRIVER={Microsoft Access Driver (*.mdb)};"
'采用Oledb方式
'connstr="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath(db)
'字符串写法的不同
'connstr="Driver={microsoft access driver (*.mdb)};DBQ=" & Server.MapPath(db)
'采用先行建立的Dsn进行连接
'connstr="dsn=hezepolice;"
conn.open connstr
以下是数据库采用sqlserver的时候Asp建立数据连接常用的代码方式之一
Set conn=Server.CreateObject("ADODB.Connection")
on error resume next
connstr="Provider=SQLOLEDB;Password=***;Persist Security Info=True;User ID=sa;Initial Catalog=msdb;Data Source=localhost;Connect Timeout=15"
conn.Open connstr
微软建议在连接Access数据库使用下面的方法:
dim conn
set conn = server.createobject("adodb.connection")
conn.open = "provider=microsoft.jet.oledb.4.0;" & "data source = " & server.mappath("data.mdb")