求一个asp数据库连接的代码conn.asp
我想要一个完整点的连数据库的代码谁有个给我个谢谢了~能够运行的错误的别发哦!我做的数据库代码很不好,我想要一个功能多点的,谁有个给我发个谢谢!!!!!!!!!!!!!!!...
我想要一个完整点的 连数据库的代码 谁有个给我个 谢谢了 ~能够运行的 错误的别发哦!
我做的数据库代码很不好,我想要一个功能多点的,谁有个给我发个谢谢 !!!!!!!!!!!!!!!!!!!我做的是ACCESS 数据库的 !!!!!!!!!!!!!!! 展开
我做的数据库代码很不好,我想要一个功能多点的,谁有个给我发个谢谢 !!!!!!!!!!!!!!!!!!!我做的是ACCESS 数据库的 !!!!!!!!!!!!!!! 展开
4个回答
展开全部
<%@ LANGUAGE = VBScript CodePage = 936%>
<%
Option Explicit
Response.Buffer = True
Dim Startime
Dim SqlNowString,Dvbbs,template,MyBoardOnline
Dim Conn,Plus_Conn,Db,MyDbPath
Const fversion="7.1.0 Sp1"
Const EnabledSession= True
Startime = Timer()
'系统采用XML版本设置
'最高版本为.4.0 依次为: Const MsxmlVersion=".3.0" Const MsxmlVersion=".2.6" 最低版本Const MsxmlVersion=""
Const MsxmlVersion=".3.0"
'可修改设置一:========================定义数据库类别,1为SQL数据库,0为Access数据库=============================
Const IsSqlDataBase = 0
MyDbPath = ""
'================================================================================================================
If IsSqlDataBase = 1 Then
'必修改设置二:========================SQL数据库设置=============================================================
'sql数据库连接参数:数据库名(SqlDatabaseName)、用户密码(SqlPassword)、用户名(SqlUsername)、
'连接名(SqlLocalName)(本地用local,外地用IP)
Const SqlDatabaseName = "dvbbs"
Const SqlPassword = "dvbbs"
Const SqlUsername = "dvbbs"
Const SqlLocalName = "(local)"
SqlNowString = "GetDate()"
Else
SqlNowString = "Now()"
End If
Const IsDeBug = 1
Set Dvbbs = New Cls_Forum
Set template = New cls_templates
Sub ConnectionDatabase
Dim ConnStr
If IsSqlDataBase = 1 Then
ConnStr = "Provider = Sqloledb; User ID = " & SqlUsername & "; Password = " & SqlPassword & "; Initial Catalog = " & SqlDatabaseName & "; Data Source = " & SqlLocalName & ";"
Else
ConnStr = "Provider = Microsoft.Jet.OLEDB.4.0;Data Source = " & Server.MapPath(MyDbPath & db)
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
End Sub
%>
动网的。仅供参考
<%
Option Explicit
Response.Buffer = True
Dim Startime
Dim SqlNowString,Dvbbs,template,MyBoardOnline
Dim Conn,Plus_Conn,Db,MyDbPath
Const fversion="7.1.0 Sp1"
Const EnabledSession= True
Startime = Timer()
'系统采用XML版本设置
'最高版本为.4.0 依次为: Const MsxmlVersion=".3.0" Const MsxmlVersion=".2.6" 最低版本Const MsxmlVersion=""
Const MsxmlVersion=".3.0"
'可修改设置一:========================定义数据库类别,1为SQL数据库,0为Access数据库=============================
Const IsSqlDataBase = 0
MyDbPath = ""
'================================================================================================================
If IsSqlDataBase = 1 Then
'必修改设置二:========================SQL数据库设置=============================================================
'sql数据库连接参数:数据库名(SqlDatabaseName)、用户密码(SqlPassword)、用户名(SqlUsername)、
'连接名(SqlLocalName)(本地用local,外地用IP)
Const SqlDatabaseName = "dvbbs"
Const SqlPassword = "dvbbs"
Const SqlUsername = "dvbbs"
Const SqlLocalName = "(local)"
SqlNowString = "GetDate()"
Else
SqlNowString = "Now()"
End If
Const IsDeBug = 1
Set Dvbbs = New Cls_Forum
Set template = New cls_templates
Sub ConnectionDatabase
Dim ConnStr
If IsSqlDataBase = 1 Then
ConnStr = "Provider = Sqloledb; User ID = " & SqlUsername & "; Password = " & SqlPassword & "; Initial Catalog = " & SqlDatabaseName & "; Data Source = " & SqlLocalName & ";"
Else
ConnStr = "Provider = Microsoft.Jet.OLEDB.4.0;Data Source = " & Server.MapPath(MyDbPath & db)
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
End Sub
%>
动网的。仅供参考
展开全部
<%@ LANGUAGE = VBScript.Encode%>
<%dim db,conn,connstr
On Error Resume Next
db="#xx.asa"
set Conn = server.CreateObject("ADODB.Connection")
connstr="driver={Microsoft Access Driver (*.mdb)};dbq="& server.MapPath("#63885451/"&db&"")/////这里就是数据库地址
conn.Open connstr
Function HtmlEncode(Content)
Content = Replace(Content, ">", ">")
Content = Replace(Content, "<", "<")
Content = Replace(Content, "'", "")
HtmlEncode = content
End Function
Function HtmlEncode2(Content)
Content = Replace(Content, ">", ">")
Content = Replace(Content, "<", "<")
Content = Replace(Content, " ", " ")
Content = Replace(Content, "'", "")
Content = Replace(Content, vbcrlf,"<br>")
HtmlEncode2 = content
End Function
function isChkInteger(para)
on error resume next
dim str
dim l,i
if isNUll(para) then
isChkInteger=false
exit function
end if
str=cstr(para)
if trim(str)="" then
isChkInteger=false
exit function
end if
l=len(str)
for i=1 to l
if mid(str,i,1)>"9" or mid(str,i,1)<"0" then
isChkInteger=false
exit function
end if
next
isChkInteger=true
if err.number<>0 then err.clear
end function
Function PageSplit(currentpage,totalpage,pagename)
if currentpage mod 10 = 0 then
Sp = currentpage \ 10
else
Sp = currentpage \ 10 + 1
end if
Pagestart = (Sp-1)*10+1
Pageend = Sp*10
strSplit = "<a href="&pagename&"?pageid=1&city="&request("city")&"><font face=webdings title=第一页>9</font></a> "
if Sp > 1 then strSplit = strSplit & "<a href="&pagename&"?pageid="&Pagestart-10&"&city="&request("city")&"><font face=webdings title=前十页>7</font></a> "
for j=PageStart to Pageend
if j > totalpage then exit for
if j <> currentpage then
strSplit = strSplit & "<a href="&pagename&"?pageid="&j&"&city="&request("city")&">["&j&"]</a> "
else
strSplit = strSplit & "<font color=red>["&j&"]</font> "
end if
next
if Sp*10 < totalpage then strSplit = strSplit & "<a href="&pagename&"?pageid="&Pagestart+10&"&city="&request("city")&"><font face=webdings title=后十页>8</font></a>"
strSplit = strSplit & "<a href="&pagename&"?pageid="&totalpage&"&city="&request("city")&"><font face=webdings title=""最后一页"">:</font></a>"
PageSplit = strSplit
End Function%>
<style>
td{font-size:9pt;line-height:120%;color:#353535}
body{font-size:9pt;line-height:120%}
a:link { color: #000000; text-decoration: none }
a:visited { color: #000000; text-decoration: none }
a:active { color: #000000; text-decoration: none }
a:hover { color: #336699; text-decoration: none; position: relative; right: 0px; top: 1px }
.pad {
PADDING-LEFT: 2px
}
</style>
<!--#include file="setup.asp"-->
<%dim db,conn,connstr
On Error Resume Next
db="#xx.asa"
set Conn = server.CreateObject("ADODB.Connection")
connstr="driver={Microsoft Access Driver (*.mdb)};dbq="& server.MapPath("#63885451/"&db&"")/////这里就是数据库地址
conn.Open connstr
Function HtmlEncode(Content)
Content = Replace(Content, ">", ">")
Content = Replace(Content, "<", "<")
Content = Replace(Content, "'", "")
HtmlEncode = content
End Function
Function HtmlEncode2(Content)
Content = Replace(Content, ">", ">")
Content = Replace(Content, "<", "<")
Content = Replace(Content, " ", " ")
Content = Replace(Content, "'", "")
Content = Replace(Content, vbcrlf,"<br>")
HtmlEncode2 = content
End Function
function isChkInteger(para)
on error resume next
dim str
dim l,i
if isNUll(para) then
isChkInteger=false
exit function
end if
str=cstr(para)
if trim(str)="" then
isChkInteger=false
exit function
end if
l=len(str)
for i=1 to l
if mid(str,i,1)>"9" or mid(str,i,1)<"0" then
isChkInteger=false
exit function
end if
next
isChkInteger=true
if err.number<>0 then err.clear
end function
Function PageSplit(currentpage,totalpage,pagename)
if currentpage mod 10 = 0 then
Sp = currentpage \ 10
else
Sp = currentpage \ 10 + 1
end if
Pagestart = (Sp-1)*10+1
Pageend = Sp*10
strSplit = "<a href="&pagename&"?pageid=1&city="&request("city")&"><font face=webdings title=第一页>9</font></a> "
if Sp > 1 then strSplit = strSplit & "<a href="&pagename&"?pageid="&Pagestart-10&"&city="&request("city")&"><font face=webdings title=前十页>7</font></a> "
for j=PageStart to Pageend
if j > totalpage then exit for
if j <> currentpage then
strSplit = strSplit & "<a href="&pagename&"?pageid="&j&"&city="&request("city")&">["&j&"]</a> "
else
strSplit = strSplit & "<font color=red>["&j&"]</font> "
end if
next
if Sp*10 < totalpage then strSplit = strSplit & "<a href="&pagename&"?pageid="&Pagestart+10&"&city="&request("city")&"><font face=webdings title=后十页>8</font></a>"
strSplit = strSplit & "<a href="&pagename&"?pageid="&totalpage&"&city="&request("city")&"><font face=webdings title=""最后一页"">:</font></a>"
PageSplit = strSplit
End Function%>
<style>
td{font-size:9pt;line-height:120%;color:#353535}
body{font-size:9pt;line-height:120%}
a:link { color: #000000; text-decoration: none }
a:visited { color: #000000; text-decoration: none }
a:active { color: #000000; text-decoration: none }
a:hover { color: #336699; text-decoration: none; position: relative; right: 0px; top: 1px }
.pad {
PADDING-LEFT: 2px
}
</style>
<!--#include file="setup.asp"-->
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
dim connstr
dim db
dim conn
db="Database/news.mdb"
'On Error Resume Next
Set conn = Server.CreateObject("ADODB.Connection")
connstr="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath(db)
conn.Open connstr
If Err Then
err.Clear
Set Conn = Nothing
Response.Write "数据库连接出错,请检查连接字串。"
Response.End
End If
Sub CloseConn()
'On Error Resume Next
Conn.close
set Conn=nothing
End sub
dim db
dim conn
db="Database/news.mdb"
'On Error Resume Next
Set conn = Server.CreateObject("ADODB.Connection")
connstr="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath(db)
conn.Open connstr
If Err Then
err.Clear
Set Conn = Nothing
Response.Write "数据库连接出错,请检查连接字串。"
Response.End
End If
Sub CloseConn()
'On Error Resume Next
Conn.close
set Conn=nothing
End sub
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
Server.Mappath("database/XX.mdb
F:\Website\Web\CnBruce\cnbruce_com\web\red\blue\database\XX.mdb
Server.Mappath("/database/XX.mdb
F:\Website\Web\CnBruce\cnbruce_com\web\database\XX.mdb
Server.Mappath("../database/XX.mdb
F:\Website\Web\CnBruce\cnbruce_com\web\red\database\XX.mdb
F:\Website\Web\CnBruce\cnbruce_com\web\red\blue\database\XX.mdb
Server.Mappath("/database/XX.mdb
F:\Website\Web\CnBruce\cnbruce_com\web\database\XX.mdb
Server.Mappath("../database/XX.mdb
F:\Website\Web\CnBruce\cnbruce_com\web\red\database\XX.mdb
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询