时间:2014-10-17 09:51:20 来源: 复制分享
Dreamweaver连接数据库教程(ASP类)
注意,后台语言不同的话连接数据库的方法也不相同,
下面的这些方法都是在Dreamweaver中ASP连接数据库的方法
ASP连接 Access 数据库方法:
这是用相对路径的: <% Set Conn=Server.CreateObject("ADODB.Connection") ConnStr="provider=Microsoft.jet.oledb.4.0;data Source="&Server.MapPath("database/data.mdb") Conn.Open ConnStr %>
下面的几种是其它常用数据库的连接方法,有需要的话可以看看
DSN
Conn.Open "DSN=AdvWorks;"&_
"Uid=Admin;"&_
"Pwd=;"
DSN文件
Conn.Open "FILEDSN=c:\somepath\mydb.dsn;" & _
"Uid=Admin;" & _
"Pwd=;"
ACCESS
Conn.Open "Driver={Microsoft Access Driver (*.mdb)};" & _
"Dbq=c:\somepath\mydb.mdb;" & _
"Uid=Admin;" & _
"Pwd=;"
Conn.Open "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=c:\somepath\myDb.mdb;" & _
"User Id=admin;" & _
"Password=;"
VF
Conn.Open "Driver={Microsoft Visual FoxPro Driver};" & _
"SourceType=DBF;" & _
"SourceDB=c:\somepath\mySourceDbFolder;" & _
"Exclusive=No;"
Excel
Conn.Open "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=c:\somepath\myExcelSpreadsheet.xls;" & _
"Extended Properties=""Excel 8.0;HDR=Yes;"";"
sql
Conn.Open "Provider=MSDASQL;" & _
"Driver={sql server};" & _
"Server=myServerName;" & _
"Database=myDatabaseName;" & _
"Uid=myUsername;" & _
"Pwd=myPassword;"
Oracle
Conn.Open "Provider=OraOLEDB.Oracle;" & _
"Data Source=MyOracleDB;" & _
"User Id=myUsername;" & _
"Password=myPassword;"