asp怎么修改conn.asp修改数据库连接,感激不尽 5
<%DimStrServer,StrUid,StrSaPwd,StrDbNameStrServer="(local)"StrUid="sa"StrSaPwd="88888...
<%
Dim StrServer,StrUid,StrSaPwd,StrDbName
StrServer="(local)"
StrUid="sa"
StrSaPwd="88888888"
StrDbName="zz8love"
StrDSN = "Provider=SQLOLEDB.1;Persist Security Info=False;User ID=" & StrUid & ";PWD=" & StrSaPwd & ";Initial Catalog=" & StrDbName & ";Data Source=" & StrServer
Set Conn = Server.CreateObject("ADODB.Connection")
Set Rs=Server.CreateObject("ADODB.RecordSet")
Conn.Open StrDSN
'关闭Rs记录
Sub RsClose()
Rs.Close
Set Rs=Nothing
End Sub
'关闭Rss记录
Sub RssClose()
Rss.Close
Set Rss=Nothing
End Sub
'关闭Conn数据源
Sub ConnClose()
Conn.Close
Set Conn=Nothing
End Sub
'取得客户端IP
Function GetIP()
UserIp = Request.ServerVariables("HTTP_X_FORWARDED_FOR")
If UserIp = "" Then UserIp = Request.ServerVariables("REMOTE_ADDR")
GetIp = UserIp
End Function
'防止SQL注入函数
Function SafeRequest(ParaName)
Dim ParaValue
ParaValue=Request(ParaName)
if IsNumeric(ParaValue) = True then
SafeRequest=ParaValue
exit Function
elseIf Instr(LCase(ParaValue),"select ") > 0 or Instr(LCase(ParaValue),"insert ") > 0 or Instr(LCase(ParaValue),"delete from") > 0 or Instr(LCase(ParaValue),"count(") > 0 or Instr(LCase(ParaValue),"drop table") > 0 or Instr(LCase(ParaValue),"update ") > 0 or Instr(LCase(ParaValue),"truncate ") > 0 or Instr(LCase(ParaValue),"asc(") > 0 or Instr(LCase(ParaValue),"mid(") > 0 or Instr(LCase(ParaValue),"char(") > 0 or Instr(LCase(ParaValue),"xp_cmdshell") > 0 or Instr(LCase(ParaValue),"exec master") > 0 or Instr(LCase(ParaValue),"net localgroup administrators") > 0 or Instr(LCase(ParaValue)," and ") > 0 or Instr(LCase(ParaValue),"net user") > 0 or Instr(LCase(ParaValue)," or ") > 0 then
Response.Write "<script language='javascript'>"
Response.Write "alert('哥们,不要乱搞!');"
Response.Write "location.href='/index.asp';"
Response.Write "</script>"
else
SafeRequest=Replace(ParaValue,"'","")
End If
End function
%><!--#include file="SqlX.Asp" --><!--#include file="ConFig.asp"--> 展开
Dim StrServer,StrUid,StrSaPwd,StrDbName
StrServer="(local)"
StrUid="sa"
StrSaPwd="88888888"
StrDbName="zz8love"
StrDSN = "Provider=SQLOLEDB.1;Persist Security Info=False;User ID=" & StrUid & ";PWD=" & StrSaPwd & ";Initial Catalog=" & StrDbName & ";Data Source=" & StrServer
Set Conn = Server.CreateObject("ADODB.Connection")
Set Rs=Server.CreateObject("ADODB.RecordSet")
Conn.Open StrDSN
'关闭Rs记录
Sub RsClose()
Rs.Close
Set Rs=Nothing
End Sub
'关闭Rss记录
Sub RssClose()
Rss.Close
Set Rss=Nothing
End Sub
'关闭Conn数据源
Sub ConnClose()
Conn.Close
Set Conn=Nothing
End Sub
'取得客户端IP
Function GetIP()
UserIp = Request.ServerVariables("HTTP_X_FORWARDED_FOR")
If UserIp = "" Then UserIp = Request.ServerVariables("REMOTE_ADDR")
GetIp = UserIp
End Function
'防止SQL注入函数
Function SafeRequest(ParaName)
Dim ParaValue
ParaValue=Request(ParaName)
if IsNumeric(ParaValue) = True then
SafeRequest=ParaValue
exit Function
elseIf Instr(LCase(ParaValue),"select ") > 0 or Instr(LCase(ParaValue),"insert ") > 0 or Instr(LCase(ParaValue),"delete from") > 0 or Instr(LCase(ParaValue),"count(") > 0 or Instr(LCase(ParaValue),"drop table") > 0 or Instr(LCase(ParaValue),"update ") > 0 or Instr(LCase(ParaValue),"truncate ") > 0 or Instr(LCase(ParaValue),"asc(") > 0 or Instr(LCase(ParaValue),"mid(") > 0 or Instr(LCase(ParaValue),"char(") > 0 or Instr(LCase(ParaValue),"xp_cmdshell") > 0 or Instr(LCase(ParaValue),"exec master") > 0 or Instr(LCase(ParaValue),"net localgroup administrators") > 0 or Instr(LCase(ParaValue)," and ") > 0 or Instr(LCase(ParaValue),"net user") > 0 or Instr(LCase(ParaValue)," or ") > 0 then
Response.Write "<script language='javascript'>"
Response.Write "alert('哥们,不要乱搞!');"
Response.Write "location.href='/index.asp';"
Response.Write "</script>"
else
SafeRequest=Replace(ParaValue,"'","")
End If
End function
%><!--#include file="SqlX.Asp" --><!--#include file="ConFig.asp"--> 展开
3个回答
展开全部
StrServer="(local)"
StrUid="sa"
StrSaPwd="88888888"
StrDbName="zz8love"
上面的就是服务器sqlserver的一些信息,一般不建议用sa登录,因为权限过高,可以新建一个普通用户只能管理这个zz8love数据库.可以通过http://www.jb51.net/article/29916.htm的设置方法。如果不是的只要修改
StrUid="sa" 这个是登录用户名
StrSaPwd="88888888" 登录密码
StrDbName="zz8love" 数据库名
StrUid="sa"
StrSaPwd="88888888"
StrDbName="zz8love"
上面的就是服务器sqlserver的一些信息,一般不建议用sa登录,因为权限过高,可以新建一个普通用户只能管理这个zz8love数据库.可以通过http://www.jb51.net/article/29916.htm的设置方法。如果不是的只要修改
StrUid="sa" 这个是登录用户名
StrSaPwd="88888888" 登录密码
StrDbName="zz8love" 数据库名
参考资料: http://www.jb51.net/article/29916.htm
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
Dim StrServer,StrUid,StrSaPwd,StrDbName
StrServer="(local)" //数据库地址,本机也可用127.0.0.1
StrUid="sa" //数据用户名
StrSaPwd="88888888" //数据密码
StrDbName="zz8love" //数据名称
StrServer="(local)" //数据库地址,本机也可用127.0.0.1
StrUid="sa" //数据用户名
StrSaPwd="88888888" //数据密码
StrDbName="zz8love" //数据名称
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
谢谢了,原来我图方便都是用SA登陆的,太感谢了
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询