ASP常用

<!--#include file="md5.asp"-->


Response.CodePage = 65001
Response.Charset="UTF-8"


'-------错误Miss---------
On Error Resume Next

'--------------------提交方式-------------
if Request.ServerVariables("REQUEST_METHOD")="POST" then


'--------------------链接数据库access-------------
  dim conn,connstr
  on error resume next
  Connstr="DRIVER=Microsoft Access Driver (*.mdb);DBQ="+server.mappath("db.mdb")
  Set Conn=Server.CreateObject("ADODB.Connection") 
  conn.Open connstr
  If Err Then
    err.Clear
    Set Conn = Nothing
    Response.Write "数据库连接出错,请检查连接字串。"
    Response.End
  End If

'------------------链接本地MSSQL2000----------------
Set conn=server.CreateObject("ADODB.Connection")
conn.Open "Provider=SQLOLEDB.1;User ID=sa;Password=sa;Initial Catalog=Local;Data Source=(local)"

'------------------链接远程MSSQL2000----------------
dim conn 
dim connstr
Dim strSQLServerName  
Dim strSQLDBUserName  
Dim strSQLDBPassword  
Dim strSQLDBName

strSQLServerName = "58.26.10.1"      '服务器名称或地址
strSQLDBUserName = "sa"             '数据库帐号
strSQLDBPassword = "f-u-c-k"               '数据库密码
strSQLDBName = "Local"             '数据库名称

Set conn = Server.CreateObject("ADODB.Connection")
connstr = "Provider=SQLOLEDB.1;Persist Security Info=False;Server=" & strSQLServerName & ";User ID=" & strSQLDBUserName & ";Password=" & strSQLDBPassword & ";Database=" & strSQLDBName & ";"
conn.open connstr


'------------------新建数据集-----------------------
set rs = Server.CreateObject("adodb.recordset")
rs.Open "select * from table ",conn,1,2    '(查询用1,2;增加和更新用3,3)


'--------------------------------------------------
'//无确认自动关闭窗口   
response.Write("<SCRIPT language=JavaScript>")   
response.Write("alert('警告!');")   
response.Write("window.opener=null; window.open('','_self'); window.close();")   
response.Write("</SCRIPT>")   
response.End()   
  
'//返回式提示   
response.write "<script language='JavaScript'>{window.alert('用户名或密码为空, 请返回重新登录');window.location='javascript:history.back();';}</script>"  
response.End()   
  
'//跳转页面式提示   
response.Write("<SCRIPT language=JavaScript>")   
response.Write("alert('警告too!');")   
response.Write("javascript:location.href='setface.asp';")   
response.Write("</SCRIPT>")

 

posted @ 2013-09-08 11:20  巫妖天下  阅读(169)  评论(0)    收藏  举报