ASP数据库连接
<%OptionExplicitDimConn,ConnStringConnString="Provider=SQLOLEDB;DataSource=(local);In...
<%
Option Explicit
Dim Conn,ConnString
ConnString = "Provider=SQLOLEDB;Data Source=(local);Initial Catalog=TEXT;User Id=sa;Password="
Sub Conn_Init()
On Error Resume Next
Set Conn=Server.CreateObject("Adodb.Connection")
Conn.Open ConnString
IF Err Then
Err.Clear
Set Conn=Nothing
Response.Write "数据库连接失败,原因:"&Err.Description&"<BR>"
Response.End()
End If
End Sub
Sub Conn_Close()
On Error Resume Next
IF IsObject(Conn) And Err.Number = 0 Then
Conn.close
Set Conn = Nothing
Exit Sub
End If
If Err Then
Err.clear
End If
End Sub
%>
我把数据库转换成MDB的了。请问如果连接到MDB数据库。一直连接不上急
大虾们那样的我都试过了没用 展开
Option Explicit
Dim Conn,ConnString
ConnString = "Provider=SQLOLEDB;Data Source=(local);Initial Catalog=TEXT;User Id=sa;Password="
Sub Conn_Init()
On Error Resume Next
Set Conn=Server.CreateObject("Adodb.Connection")
Conn.Open ConnString
IF Err Then
Err.Clear
Set Conn=Nothing
Response.Write "数据库连接失败,原因:"&Err.Description&"<BR>"
Response.End()
End If
End Sub
Sub Conn_Close()
On Error Resume Next
IF IsObject(Conn) And Err.Number = 0 Then
Conn.close
Set Conn = Nothing
Exit Sub
End If
If Err Then
Err.clear
End If
End Sub
%>
我把数据库转换成MDB的了。请问如果连接到MDB数据库。一直连接不上急
大虾们那样的我都试过了没用 展开
5个回答
展开全部
帮你改了连接字符串!
<%
Option Explicit
Dim Conn,ConnString
path = server.MapPath("zzz.mdb")
ConnString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & path
Sub Conn_Init()
On Error Resume Next
Set Conn=Server.CreateObject("Adodb.Connection")
Conn.Open ConnString
IF Err Then
Err.Clear
Set Conn=Nothing
Response.Write "数据库连接失败,原因:"&Err.Description&"<BR>"
Response.End()
End If
End Sub
Sub Conn_Close()
On Error Resume Next
IF IsObject(Conn) And Err.Number = 0 Then
Conn.close
Set Conn = Nothing
Exit Sub
End If
If Err Then
Err.clear
End If
End Sub
%>
<%
Option Explicit
Dim Conn,ConnString
path = server.MapPath("zzz.mdb")
ConnString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & path
Sub Conn_Init()
On Error Resume Next
Set Conn=Server.CreateObject("Adodb.Connection")
Conn.Open ConnString
IF Err Then
Err.Clear
Set Conn=Nothing
Response.Write "数据库连接失败,原因:"&Err.Description&"<BR>"
Response.End()
End If
End Sub
Sub Conn_Close()
On Error Resume Next
IF IsObject(Conn) And Err.Number = 0 Then
Conn.close
Set Conn = Nothing
Exit Sub
End If
If Err Then
Err.clear
End If
End Sub
%>
展开全部
ConnString = "Provider=SQLOLEDB;Data Source=(local);Initial Catalog=TEXT;User Id=sa;Password="
改成
ConnString="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath("你的MDB数据库地址")
改成
ConnString="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath("你的MDB数据库地址")
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
用我这段时, MDB数据库的, 超简单,
<%
Dim Conn, ConnStr, SiteDataAccess
SiteDataAccess="/db/数据库名称.mdb" '这是绝对路径根目录下的DB目录
Set Conn = Server.CreateObject("Adodb.Connection")
ConnStr = "Provider = Microsoft.Jet.OLEDB.4.0;Data Source = " & Server.MapPath(""&SiteDataAccess&"")
Conn.Open ConnStr
If Err Then
Err.Clear
Set Conn = Nothing
Response.Write "连接出错!"
Response.End
End If
%>
<%
Dim Conn, ConnStr, SiteDataAccess
SiteDataAccess="/db/数据库名称.mdb" '这是绝对路径根目录下的DB目录
Set Conn = Server.CreateObject("Adodb.Connection")
ConnStr = "Provider = Microsoft.Jet.OLEDB.4.0;Data Source = " & Server.MapPath(""&SiteDataAccess&"")
Conn.Open ConnStr
If Err Then
Err.Clear
Set Conn = Nothing
Response.Write "连接出错!"
Response.End
End If
%>
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
把这句ConnString = "Provider=SQLOLEDB;Data Source=(local);Initial Catalog=TEXT;User Id=sa;Password="改成下面的语句:
xuasmdb="数据库路径"
DBPath = Server.MapPath(xuasmdb)
ConnString ="Provider=Microsoft.Jet.OLEDB.4.0; Data Source="&DBPath
xuasmdb="数据库路径"
DBPath = Server.MapPath(xuasmdb)
ConnString ="Provider=Microsoft.Jet.OLEDB.4.0; Data Source="&DBPath
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
最佳答案,已经产生
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询