Vbscript FUNCTION
Function counter(x,y)
dim sum, prod
sum = x + y
prod = x * y
counter = "the sum is: " & sum & vbnewline & "and the product is: "
& prod
End function
The function name "counter" would then be misleading, though, would it not?
Vbscript BeginTrans/commit
'The next line starts a transaction
[Link]
Set adoCmd = [Link]("[Link]")
'I added this to give the command 45 seconds to execute.
[Link] = 45
[Link] = adoConn
[Link] = "sproc_RecalculateQuantities"
[Link] = adCmdStoredProc
[Link]
Set colErrs=[Link]
If [Link] <> 0 then
For Each objError In colErrs
'This is the error number for a timeout.
If [Link]=-2147217871 Then
[Link]
[Link] "The query timed out before finishing. Please try again."
timeout=True
[Link]
Exit For
End If
Next
End If
Set adoCmd = Nothing
If Not timeout Then
[Link]
End If
[Link]
Set adoConn = Nothing
[Link] ' Begin transaction.
SQL = "Delete * from Faculty where " & _
"FacultyID = '100000000'"
[Link] SQL, nRecords
TotalErrors = [Link]
SQL = "Delete * from FacultyReference " & _
"where FacultyID = '100000000'"
[Link] SQL, nRecords
TotalErrors = TotalErrors + [Link]
If TotalErrors = o Then
[Link]
Else
[Link]
End If
Vbscript Checkbox array/split
choices = [Link]("computer")
choices = Split(choices, ",")
For Each member in choices
[Link] member & "<BR>"
Next
VBscript Session Variables
Session("UserName") = [Link]("UserName")
<%=Session("UserName")%>
VBscript Header Request
<%= [Link]("HTTP_PROVIDERID") %>
VBscript Recordset Variables
<%=([Link]("dv_prov_id").Value)%>
SQL Update Statement
UPDATE table_name
SET column_name = new_value
WHERE column_name = some_value
UPDATE Person
SET Address = 'Stien 12', City = 'Stavanger'
WHERE LastName = 'Rasmussen'
UPDATE dbo…
SET Address = 'Stien 12', City = 'Stavanger'
WHERE LastName = 'Rasmussen'
Error Handling
[Link] (gives a description of the error) [Link] (the error code that was
associated with the error) [Link] (initiates an error code) [Link] (clears the values of
the Err object – resetting all values)
------------------- Begin Code Snippet ------------------- On Error Resume Next
' Regular code here....
[Link](7) 'Simulate and "out of memory" Error 'Check to see if any errors have occurred. If
[Link] <> 0 Then 'Capture, display, and clear error [Link] Computer & " " &
[Link] [Link] Else [Link] "No errors encountered." End If--------------------
End Code Snippet --------------------
<%
else
sql="DELETE FROM customers"
sql=sql & " WHERE customersID='" & cid & "'"
on error resume next
[Link] sql
if err<>0 then
[Link]("No update permissions!")
else
[Link]("Record " & cid & " was deleted!")
end if
end if
[Link]
%>