动网论坛的asp 数据库连接代码
程序员文章站
2023-09-06 16:48:16
复制代码 代码如下:<%@language="vbscript"%> <% option explicit dim startime,endtime,co...
复制代码 代码如下:
<%@language="vbscript"%>
<%
option explicit
dim startime,endtime,conn,strcon,db
startime=timer()
dim strsqlservername
dim strsqldbusername
dim strsqldbpassword
dim strsqldbname
'请填写数据库具体参数
'-----------------------------------------------------------------------------------------------
strsqlservername = "127.0.0.1" '服务器名称或地址
strsqldbusername = "sa" '数据库帐号
strsqldbpassword = "123" '数据库密码
strsqldbname = "bbsbak" '数据库名称
'-----------------------------------------------------------------------------------------------
'sql server ole driver
set conn = server.createobject("adodb.connection")
strcon = "provider=sqloledb;server=" & strsqlservername & ";user id=" & strsqldbusername & ";password=" & strsqldbpassword & ";database=" & strsqldbname & ";"
conn.open strcon
function closedatabase
conn.close
set conn = nothing
end function
%>