The common function _fso topic of ASP

Source: Internet
Author: User
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
%>

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.