I am trying to run the following vbscript code (see SCRIPT CODE below)
using an onclick event on a button(see BUTTON CODE below). I am
getting the "error: object expected" at the button code line.
Is there a fundamental problem with my script , i.e. trying to run a
server side script using a button or is there merely a coding error???
I was hoping to run this code automatically when the page loads
pulling in the txt_ClientCode value from a cookie but when i used the
line txt_ClientCode = request.cookie("ClientCode") and ran the code as
client side script i got an error on the word request. Can anyone
please give me a few explanations as to what is happening and any
helpful hints.
BUTTON CODE
<input name="testname" type=button onclick="TestMsg()"
style="width:105px;">
SCRIPT CODE
<SCRIPT LANGUAGE=vbscript runat=server>
Function TestMsg()
Dim oRS, strSQL, txt_ClientCode
txt_ClientCode = "G10"
If len(txt_ClientCode)>0 Then
strSQL = "Select ClientCode, PDFName From tbl_PaymentProtectionPDF
Where ClientCode='" & txt_ClientCode & "'"
Set oRS = Server.CreateObject("ADODB.RecordSet")
oRS.Open strSQL,Application("ConnectionString"),adOpenKeyset,adLockOptimistic
If Not (oRS.EOF And oRS.BOF) Then
msgbox(oRS("ClientCode"))
oRS.Delete
oRS.Update
End IF
oRS.Close
Set oRS = Nothing
Response.End
End If
end function
</SCRIPT>
Thanks