如何将asp网页连接到access数据库???
2个回答
展开全部
一、MS Access 数据库
1、OLE[推荐]
Dim Conn,ConnStr,DBPath
DBPath = "DataBase.mdb"
ConnStr = "Provider = Microsoft.Jet.OLEDB.4.0;Data Source = "&Server.MapPath(DBPath)
'当数据库设置过密码时用以下语句
ConnStr = "Provider = Microsoft.Jet.OLEDB.4.0;Data Source = "& Server.MapPath(DBPath) &";
Jet OLEDB:Database Password=Password"
On Error Resume Next
Set Conn = Server.CreateObject("ADODB.Connection")
Conn.Open ConnStr
If Err Then
Err.Clear
Conn.Close
Set Conn = Nothing
Response.Write("数据库链接出错,请检查链接字符串。")
Response.End()
Else
Response.Write("数据库链接成功!")
End If
2、ODBC
Dim Conn,ConnStr,DBPath
DBPath = "DataBase.mdb"
ConnStr="DRIVER={Microsoft Access Driver (*.mdb)};DBQ="& Server.MapPath(DBPath) &""
'当数据库设置过密码时用以下语句,以下PWD也可写成Password
'ConnStr="DRIVER={Microsoft Access Driver (*.mdb)};DBQ="& Server.MapPath(DBPath) &";
PWD=Password"
On Error Resume Next
Set Conn = Server.CreateObject("ADODB.Connection")
Conn.Open ConnStr
If Err Then
Err.Clear
Conn.Close
Set Conn = Nothing
Response.Write("数据库链接出错,请检查链接字符串。")
Response.End()
Else
Response.Write("数据库链接成功!")
End If
1、OLE[推荐]
Dim Conn,ConnStr,DBPath
DBPath = "DataBase.mdb"
ConnStr = "Provider = Microsoft.Jet.OLEDB.4.0;Data Source = "&Server.MapPath(DBPath)
'当数据库设置过密码时用以下语句
ConnStr = "Provider = Microsoft.Jet.OLEDB.4.0;Data Source = "& Server.MapPath(DBPath) &";
Jet OLEDB:Database Password=Password"
On Error Resume Next
Set Conn = Server.CreateObject("ADODB.Connection")
Conn.Open ConnStr
If Err Then
Err.Clear
Conn.Close
Set Conn = Nothing
Response.Write("数据库链接出错,请检查链接字符串。")
Response.End()
Else
Response.Write("数据库链接成功!")
End If
2、ODBC
Dim Conn,ConnStr,DBPath
DBPath = "DataBase.mdb"
ConnStr="DRIVER={Microsoft Access Driver (*.mdb)};DBQ="& Server.MapPath(DBPath) &""
'当数据库设置过密码时用以下语句,以下PWD也可写成Password
'ConnStr="DRIVER={Microsoft Access Driver (*.mdb)};DBQ="& Server.MapPath(DBPath) &";
PWD=Password"
On Error Resume Next
Set Conn = Server.CreateObject("ADODB.Connection")
Conn.Open ConnStr
If Err Then
Err.Clear
Conn.Close
Set Conn = Nothing
Response.Write("数据库链接出错,请检查链接字符串。")
Response.End()
Else
Response.Write("数据库链接成功!")
End If
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询