ASP commonly used functions, I hope to be able to use.
<%
Dim db
db= "Dbms.mdb"
'******************************************************************
' Execute the SQL statement, do not return a value, the SQL statement best is as follows:
' Update table name set field name =value, field name =value where field name =value
' Delete from table name where field name =value
' Insert into table name (field name, field name) VALUES (value,value)
'******************************************************************
Sub noresult (SQL)
Dim conn
Dim connstr
Set conn = Server.CreateObject ("ADODB. Connection ")
Connstr= "Provider=Microsoft.Jet.OLEDB.4.0;Data source=" & Server.MapPath ("&db&")
Conn. Open ConnStr
Conn.execute SQL
Conn.close
Set conn=nothing
End Sub
'*******************************************************************
' Executes the SELECT statement, returning the Recordset object. The object is read-only. Which means you can't update it.
'*******************************************************************
Function result (SQL)
Dim conn
Dim connstr
Dim rcs
Set conn = Server.CreateObject ("ADODB. Connection ")
Connstr= "Provider=Microsoft.Jet.OLEDB.4.0;Data source=" & Server.MapPath ("&db&")
Conn. Open ConnStr
Set RCS = Server.CreateObject ("ADODB.") Recordset ")
Rcs.open sql,conn,1,1
Set result = RCS
End Function
'*******************************************************************
' Pop-up dialog box
'*******************************************************************
SUB Alert (message)
message = replace (message, "'", "\")
Response.Write ("<script>alert" (' & Message & ') </script> ")
End Sub
'*******************************************************************
' Returns to the previous page, generally used to determine whether the information is submitted completely
'*******************************************************************
Sub GoBack ()
Response.Write ("<script>history.go ( -1) </script>")
End Sub
'*******************************************************************
' Redirect Additional connections
'*******************************************************************
Sub Go (URL)
Response.Write ("<script>location.href (' & URL & ') </script>")
End Sub
'*******************************************************************
' Replace the HTML tag
'*******************************************************************
function Htmlencode2 (str)
Dim result
Dim l
If IsNULL (str) Then
Htmlencode2= ""
Exit function
End If
L=len (str)
Result= ""
Dim i
For i = 1 to L
Select Case Mid (str,i,1)
Case "<"
Result=result+ "<"
Case ">"
result=result+ ">"
Case Chr (13)
result=result+ "<br>"
Case Chr (34)
result=result+ "" "
Case "&"
result=result+ "&"
Case Chr (32)
' Result=result+ ' "
If I+1<=l and i-1>0 then
If Mid (str,i+1,1) =CHR or mid (str,i+1,1) =CHR (9) or mid (str,i-1,1) =CHR (?) or mid (str,i-1,1) =CHR (9) Then
Result=result+ ""
Else
Result=result+ ""
End If
Else
Result=result+ ""
End If
Case Chr (9)
Result=result+ ""
Case Else
Result=result+mid (str,i,1)
End Select
Next
Htmlencode2=result
End Function
'*******************************************************************
' Check if there are single quotes in the SQL string, then convert
'*******************************************************************
function Checkstr (str)
Dim tstr,l,i,ch
str = Trim (str)
L=len (str)
For I=1 to L
Ch=mid (str,i,1)
If ch= "'" Then
tstr=tstr+ "'"
End If
Tstr=tstr+ch
Next
Checkstr=tstr
End Function
%>