3个回答
展开全部
给个精简版的给你
connstr="Provider=Microsoft.Jet.OLEDB.4.0;Data Source="&Server.MapPath("data/data.mdb")&""
'如你的数据库放在data/data,mdb
'response.Write(connstr)
Set conn = Server.CreateObject("ADODB.Connection")
conn.open connstr
Set rs = Server.CreateObject("ADODB.Recordset")
sql="select * from mytable"
'数据库中有个mytable表,查询就是这样了
rs.open sql,conn,1,1
response.Write(rs("id"))
connstr="Provider=Microsoft.Jet.OLEDB.4.0;Data Source="&Server.MapPath("data/data.mdb")&""
'如你的数据库放在data/data,mdb
'response.Write(connstr)
Set conn = Server.CreateObject("ADODB.Connection")
conn.open connstr
Set rs = Server.CreateObject("ADODB.Recordset")
sql="select * from mytable"
'数据库中有个mytable表,查询就是这样了
rs.open sql,conn,1,1
response.Write(rs("id"))
展开全部
给你个经典的:
<%
Response.Charset="gb2312"
Dim Conn
Dim ConnSt
Call MyConn()
Sub MyConn()
Set Conn = Server.CreateObject("ADODB.Connection")
ConnStr = "DBQ="&Server.Mappath("/Data/Shop.mdb")&";DefaultDir=;Driver={Microsoft Access Driver (*.mdb)};"
If Err.Number <> 0 Then
Err.Clear
Set Conn = Nothing
Response.Write "Error"
Response.End
Else
Conn.Open ConnStr
If Err Then
Err.Clear
Set Conn = Nothing
Response.Write "Error"
Response.End
End If
End If
End sub
%>
<%
Response.Charset="gb2312"
Dim Conn
Dim ConnSt
Call MyConn()
Sub MyConn()
Set Conn = Server.CreateObject("ADODB.Connection")
ConnStr = "DBQ="&Server.Mappath("/Data/Shop.mdb")&";DefaultDir=;Driver={Microsoft Access Driver (*.mdb)};"
If Err.Number <> 0 Then
Err.Clear
Set Conn = Nothing
Response.Write "Error"
Response.End
Else
Conn.Open ConnStr
If Err Then
Err.Clear
Set Conn = Nothing
Response.Write "Error"
Response.End
End If
End If
End sub
%>
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
连接字符串
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询