yasuru
04-02-2004, 09:23 PM
I need to send mail to the user who filled up the form, but only after the data get inserted in database. For that I am inserting sessionID with other data and then on the next page calling the data using the same SessionID and sending the mail to the user. Here I want to catch error if occured. Program is working fine, but I dont know whether I put the error code in the right place or not. I shall be thankful to you if you help me with this. Thanks
Herez my code:
<%
sess = Session("sessID")
Dim con 'Holds the Database Connection Object
Dim rs 'Holds the recordset for the records in the database
Dim strSQL 'Holds the SQL query to query the database
Dim errSQL ''Holds the errSQL query to query the database
Set con = Server.CreateObject("ADODB.Connection")
con.Open "DSN=test"
Set rs = Server.CreateObject("ADODB.Recordset")
strSQL = "SELECT * FROM order WHERE sessID = '" &sess& "'"
rs.Open strSQL, con
'------Check Error-----------
If(err.number <> 0) Then
Response.write("<strong>" & "Error Occured:" & err.description & "</strong>")
errSQL = "INSERT INTO errLog (errDate, errTime, errDesc)"
errSQL = errSQL & "VALUES ('" & date
errSQL = errSQL & "','" & time
'errSQL = errSQL & "','" & err.description & "')"
con.Execute(errSQL)
ELSE
'----------ELSE SEND E-MAIL----------------------------
On Error Resume Next
rs.MoveFirst
do while Not rs.eof
'-----------SEND MAIL USING (BASP21)---------------***********************
'----P.S. (CDONTS not using on purpose)------//
email1 = rs("email1")
'------------------------------------------------------///
Set ObjBasp = Server.CreateObject("basp21")
Const m_sv = "mail.co-123"
m_from = ***@***.com
m_title = "Thanks"
m_body = "Thanks, & rs("name1") & vbcrlf & _
"Your address is:" & rs("address")
rc = ObjBasp.SendMail(m_sv,email1,m_from,m_title,m_body,"")
'------------END OF SENDING EMAIL-----------------**********
rs.MoveNext
loop
'-------------------------------------------------------------
Session.Abandon
Response.Redirect("thanks.asp")
end if
con.close
set con = nothing
%>
Herez my code:
<%
sess = Session("sessID")
Dim con 'Holds the Database Connection Object
Dim rs 'Holds the recordset for the records in the database
Dim strSQL 'Holds the SQL query to query the database
Dim errSQL ''Holds the errSQL query to query the database
Set con = Server.CreateObject("ADODB.Connection")
con.Open "DSN=test"
Set rs = Server.CreateObject("ADODB.Recordset")
strSQL = "SELECT * FROM order WHERE sessID = '" &sess& "'"
rs.Open strSQL, con
'------Check Error-----------
If(err.number <> 0) Then
Response.write("<strong>" & "Error Occured:" & err.description & "</strong>")
errSQL = "INSERT INTO errLog (errDate, errTime, errDesc)"
errSQL = errSQL & "VALUES ('" & date
errSQL = errSQL & "','" & time
'errSQL = errSQL & "','" & err.description & "')"
con.Execute(errSQL)
ELSE
'----------ELSE SEND E-MAIL----------------------------
On Error Resume Next
rs.MoveFirst
do while Not rs.eof
'-----------SEND MAIL USING (BASP21)---------------***********************
'----P.S. (CDONTS not using on purpose)------//
email1 = rs("email1")
'------------------------------------------------------///
Set ObjBasp = Server.CreateObject("basp21")
Const m_sv = "mail.co-123"
m_from = ***@***.com
m_title = "Thanks"
m_body = "Thanks, & rs("name1") & vbcrlf & _
"Your address is:" & rs("address")
rc = ObjBasp.SendMail(m_sv,email1,m_from,m_title,m_body,"")
'------------END OF SENDING EMAIL-----------------**********
rs.MoveNext
loop
'-------------------------------------------------------------
Session.Abandon
Response.Redirect("thanks.asp")
end if
con.close
set con = nothing
%>