一聚教程网:一个值得你收藏的教程网站

热门教程

完整asp数据库代码(access,mssql)

时间:2022-06-30 10:09:05 编辑:袖梨 来源:一聚教程网

set conn=server.createobject("adodb.connection")
connstr="provider=microsoft.jet.oledb.4.0;data source="&server.mappath("/www.111com.net/data.mdb")
conn.open connstr
%>


<%

response.buffer = true

const msxmlversion=".3.0"
const cookiename = "netpic"

dim conn,connstr,datafile
startime = timer()

'可修改设置一:========================定义数据库类别,1为sql数据库,0为access数据库=============================
const issqldatabase = 0
'================================================================================================================
if issqldatabase = 1 then
 '必修改设置二:========================sql数据库设置=============================================================
 'sql数据库连接参数:连接名(sqllocalname)(本地用local,外地用ip)、用户名(sqlusername)、用户密码(sqlpassword)、数据库名(sqldatabasename)
 const sqllocalname = "(local)"
 const sqlusername = "sa"
 const sqlpassword = "001225"
 const sqldatabasename = "photo"
 '================================================================================================================
 datestring = array("getdate()","yyyy","m","d","hh","n","s","'")
 
 connstr = "driver={sql server};uid=" & sqlusername & ";pwd=" & sqlpassword & ";database=" & sqldatabasename & ";server=" & sqllocalname & ";"
else
 '必修改设置三:========================access数据库设置==========================================================
 datafile = server.mappath("data/#photo.mdb")
 '================================================================================================================
 datestring = array("now()","'yyyy'","'m'","'d'","'h'","'n'","'s'","#")
 
 connstr = "provider = microsoft.jet.oledb.4.0;data source = " & datafile
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
 
function checked(value1,value2)
 checked = " value="&chr(34)&value2&chr(34)
 if lcase(value1&"")=lcase(value2&"") then checked = checked & " checked"
end function

function selected(value1,value2)
 selected = " value="&chr(34)&value2&chr(34)
 if lcase(value1&"")=lcase(value2&"") then selected = selected & " selected"
end function
%>

热门栏目