当前位置:Gxlcms > mysql > 完整asp数据库代码(access,mssql)

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

时间:2021-07-01 10:21:17 帮助过:59人阅读

完整 asp 数据库 代码 (access,mssql)'本文章提供这款asp 数据库 连接 代码 是一款可以与mssql server与access 数据库 连接的文件,包括有最简单的连接方法。 完整 asp教程 数据库 教程 代码 (access,mssql) '本文章提供这款asp 数据库 连接 代码 是一款可

完整asp数据库代码(access,mssql) '本文章提供这款asp数据库连接代码是一款可以与mssql server与access数据库连接的文件,包括有最简单的连接方法。

完整asp教程数据库教程代码(access,mssql)
'本文章提供这款asp数据库连接代码是一款可以与mssql server与access数据库连接的文件,包括有最简单的连接方法。
set conn=server.createobject("adodb.connection")
connstr="provider=microsoft.jet.oledb.4.0;data source="&server.mappath("/www.111cn.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
%>

人气教程排行