最新下载
热门教程
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
asp 全面安全数据连接代码
时间:2009-06-02 编辑:简简单单 来源:一聚教程网
<%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>
<%
dim DataLinkType,conn,connstr,MyDbPath
MyDbPath="data/Database.mdb" '数据库文件位置
DataLinkType = 0 '设置数据库连接方式,1为SQL数据库,0为Access数据库
If dataLinkType=0 Then
'**************************************************
'使用Access数据库
'**************************************************
ConnStr = "Provider = Microsoft.Jet.OLEDB.4.0;Data Source = " & Server.MapPath(MyDbPath)
Else
'**************************************************
'使用SQL数据库
'**************************************************
'ConnStr = "Driver={SQL Server}; server=(local);uid=sa;pwd=windows;database=data1;"
ConnStr = "Provider=SQLNCLI; server=.SQLEXPRESS;uid=sa;pwd=windows;database=data1;"
End If
On Error Resume Next
Set conn = Server.CreateObject("ADODB.Connection")
conn.open ConnStr
If Err Then
Err.Clear
Set Conn = Nothing
Response.Write "数据库连接出错,请检查连接字串。"'注释,需要把这几个字翻译成英文。
Response.End
End If
'**************************************************
'关闭数据库
'**************************************************
sub CloseConn()
conn.close
set conn=nothing
end sub
%>
-
下一个: asp 入门教程-读取数据库信息并更新
相关文章
- asp 高级数据连接方法 05-12
- asp数据连接库代码 04-24
- asp数据连接代码 03-20
- asp数据连接方法 01-19
- VBS 批量Ping的项目讲解 09-19
- 如何封装一个Ajax函数介绍 09-16