ASP commonly used function
ASP commonly used function, in the hope that use.
<%
Dim db
Db = "dbms.mdb"
'************************************************* *****************
'Implementation sql statement, does not return value, the best sql statement is as follows:
'Update table set field name = value, the field name = value where field name = value
'Delete from table where field name = value
'Insert into a table (field names, field names) 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
'************************************************* ******************
'Implementation of select statements, returning to the recordset object. The CD-object. That is not updated
'************************************************* ******************
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
'************************************************* ******************
'Back, the general use in judging whether the information submitted after full
'************************************************* ******************
Sub GoBack ()
Response.write ( "<script> history.go (-1) </ script>")
End Sub
'************************************************* ******************
'Redirect another link
'************************************************* ******************
Sub Go (url)
Response.write ( "<script> location.href ( '" & & url "')</ script> ")
End Sub
'************************************************* ******************
'To replace html tags
'************************************************* ******************
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 (32) or mid (str, i +1,1) = chr (9) or mid (str, i-1, 1) = chr (32) 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
'************************************************* ******************
'String sql check whether there are single quotes, while conversion
'************************************************* ******************
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
%>








0 Comments to “ASP commonly used function”
No Comments. Send your comment.
Leave a Reply
You must be logged in to post a comment.