ASP动态网页怎么与sql数据库连接呢?
- 提问者网友:做自己de王妃
- 2021-07-17 09:08
- 五星知识达人网友:怀裏藏嬌
- 2021-07-17 09:29
楼上的比较完整。。。但是对初学者。。。下面就够了
<%dim rs,conn
set conn=Server.CreateObject("ADODB.Connection")
conn.open "provider=microsoft.jet.oledb.4.0;data source="&server.mappath("mydata.mdb")
set rs=server.createobject("adodb.recordset")
%>
- 1楼网友:独钓一江月
- 2021-07-17 09:59
<% Option Explicit session.CodePage = 65001 Response.Buffer = True Dim StarTime Dim Conn,Rs,Sql,ConnStr,Db
Sub ConnectionDatabase() ConnStr = "Provider = Microsoft.Jet.OLEDB.4.0;Data Source = " & Server.MapPath("data.mdb")
On Error Resume Next Set Conn = Server.CreateObject("ADODB.Connection") Set Rs=Server.CreateObject("ADODB.Recordset") Conn.Open ConnStr If Err Then err.Clear Set Conn = Nothing Response.Write("数据库连接出错,请检查连接字串") Response.End End If End Sub
Sub DisConnectionDatabase() ' Rs.Close Set Rs=Nothing Conn.Close Set Conn=Nothing End Sub %>