如何利用ASP文件连接MDB数据库
如何利用ASP文件连接MDB数据库,我是想用网也的形式用SQL语句做数据库的查询和处理,用什么代码及文件?...
如何利用ASP文件连接MDB数据库,我是想用网也的形式用SQL语句做数据库的查询和处理,用什么代码及文件?
展开
2个回答
展开全部
<%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>
<%
Option Explicit
Response.Buffer = True
Response.ContentType = "text/html"
Response.CharSet = "gb2312"
Server.ScriptTimeOut = 90
Session.CodePage = 936
Session.LCID = 2052
'定义数据库链接文件,根据自己的情况修改
Const AccessFile = "db/db.mdb"
'定义数据库连接
Dim CONN, RST, SQLStr
'ON ERROR RESUME NEXT
Set Conn= Server.CreateObject("ADODB.Connection")
Conn.ConnectionString="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath(AccessFile)
Conn.Open
If Err Then
Err.Clear
Set Conn = Nothing
Response.Write("<meta http-equiv=""Content-Type"" content=""text/html; charset=GB2312"" /><div style=""font-size:12px;font-weight:bold;border:1px solid #006;padding:6px;background:#fcc"">数据库连接出错,请检查连接字串!</div>")
Response.End
End If
%>
<%
Option Explicit
Response.Buffer = True
Response.ContentType = "text/html"
Response.CharSet = "gb2312"
Server.ScriptTimeOut = 90
Session.CodePage = 936
Session.LCID = 2052
'定义数据库链接文件,根据自己的情况修改
Const AccessFile = "db/db.mdb"
'定义数据库连接
Dim CONN, RST, SQLStr
'ON ERROR RESUME NEXT
Set Conn= Server.CreateObject("ADODB.Connection")
Conn.ConnectionString="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath(AccessFile)
Conn.Open
If Err Then
Err.Clear
Set Conn = Nothing
Response.Write("<meta http-equiv=""Content-Type"" content=""text/html; charset=GB2312"" /><div style=""font-size:12px;font-weight:bold;border:1px solid #006;padding:6px;background:#fcc"">数据库连接出错,请检查连接字串!</div>")
Response.End
End If
%>
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询