db.asp

来自「办公系统」· ASP 代码 · 共 61 行

ASP
61
字号
<!--#include file="Style.css"-->
<%
'定义数据库操作的各个变量
dim sql
dim rs
dim conn
'打开数据库
sub openDB()
	set conn=server.createobject("ADODB.Connection") 
	conn.open"Driver={SQL Server};"_ 
	&"Server=localhost;" _
	&"Database=Office;" _
	&"Uid=sa;" _
	&"Pwd=123"
	set rs=server.createobject("ADODB.Recordset")
end sub
'关闭数据库
sub closeDB()
	If IsObject(conn) Then
		if not(conn is nothing) then
			set rs=nothing
			conn.close
			set conn=nothing
		end if
	End If
end sub
'身份验证
sub insureID()
	if session("User_id")="" then
		call closeDB()
		response.redirect "../reload.htm"
	end if
end sub
'当操作没有取得应有的权力时,显示错误信息
sub noRight()
	response.write "<div height=50 align=center valign=center>您没有进行此操作的权限,操作被取消.</div>"
	call closeDB()
	response.end
end sub
'系统产生错误时,显示错误信息
sub trigErr()
	response.write "<div height=50 align=center valign=center>有错误发生,操作被取消.</div>"
	call closeDB()
	response.end
end sub
'将从客户端的文本数据存入到数据库的时候不能有撇号,每次Insert和Update之前,都要先替换掉撇号
function replacePrime(strItem)
	if strItem="" then
		call trigErr()
	end if
	replacePrime=replace(strItem,"'","#Rep_PRIME_lace#")
end function
'从数据库读取文本后,在发送到客户端之前应该将把撇号替换回来
function replaceBack(strItem)
	if strItem="" then
		call trigErr()
	end if
	replaceBack=replace(strItem,"#Rep_PRIME_lace#","'")
end function

%>

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?