Whing Dela Cruz
asked on
ASP exit
Hi experts, How to exit ASP? Or What is the equivalent of exit sub in vb to ASP?
Something like this inside my ASP code. I want to exit If not .BOF = True And not .EOF = True Then
<%
with rs
If not .BOF = True And not .EOF = True Then
exit sub
end if
end with
%>
Something like this inside my ASP code. I want to exit If not .BOF = True And not .EOF = True Then
<%
with rs
If not .BOF = True And not .EOF = True Then
exit sub
end if
end with
%>
your code is a bit unclear on what you're trying to accomplish, as you're not any any kind of loop to exit. what your code says is if there is any data in the recordset, go away and do nothing. what ultimately are you trying to accomplish?
maybe posting more code would clear up what you want to do.
do you want to check for data in the rs object, and if any is found, execute more code? if so, try this:
do you want to check for data in the rs object, and if any is found, execute more code? if so, try this:
<%
If not rs.BOF And not rs.EOF Then '-- shorthand for what you had, this IF statement will execute code if records are found, otherwise it does nothing
with rs
end with
end if
%>
ASKER
Hi Monty, I trying to exit or go away or end if the record on the recordset is existing. If record is existing I want to cancel all remaining transaction on the ASP. And I want to have a message alert (Javascript) that says, "Record is existing". Thanks!
can you post all of the code you have so far?
ASKER
Hi Monty, this is the code
<%
fname = Request.Form("cname")
lname = Request.Form("lname")
mbnumb = Request.Form("mbnumber")
addre = Request.Form("add1")
psword = Request.Form("psw")
Set cn = Server.CreateObject("ADODB .Connectio n")
Set rs = Server.CreateObject("ADODB .Recordset ")
cn.ConnectionString = "driver={SQL Server};server=PCSERVER;ui d=;pwd=;da tabase=iDB "
cn.Open
Set rs = cn.Execute("Select Mnumber from MyMembers where Mnumber='" & mbnumb & "'")
with rs
If not .BOF = True And not .EOF = True Then
end or Javascript message "Data is existing"
else
'Continue doing here
end if
end with
%>
<%
fname = Request.Form("cname")
lname = Request.Form("lname")
mbnumb = Request.Form("mbnumber")
addre = Request.Form("add1")
psword = Request.Form("psw")
Set cn = Server.CreateObject("ADODB
Set rs = Server.CreateObject("ADODB
cn.ConnectionString = "driver={SQL Server};server=PCSERVER;ui
cn.Open
Set rs = cn.Execute("Select Mnumber from MyMembers where Mnumber='" & mbnumb & "'")
with rs
If not .BOF = True And not .EOF = True Then
end or Javascript message "Data is existing"
else
'Continue doing here
end if
end with
%>
try the following:
<%
fname = Request.Form("cname")
lname = Request.Form("lname")
mbnumb = Request.Form("mbnumber")
addre = Request.Form("add1")
psword = Request.Form("psw")
Set cn = Server.CreateObject("ADODB.Connection")
Set rs = Server.CreateObject("ADODB.Recordset")
cn.ConnectionString = "driver={SQL Server};server=PCSERVER;uid=;pwd=;database=iDB"
cn.Open
Set rs = cn.Execute("Select Mnumber from MyMembers where Mnumber='" & mbnumb & "'")
if not rs.BOF and not rs.EOF then '-- record found
Response.Write "this record already exists"
else
with rs
'Continue doing here
end with
end if
%>
ASKER
Thanks Monty, and Is it possible to make a message alert here using JavaScript? Please give me solution or overview before I close this question. Thanks!
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
is this what you're looking to do?
ASKER
Thanks a lot Monty, Its working..