Avatar of Whing Dela Cruz
Whing Dela Cruz
Flag for Anguilla 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
%>
ASP

Avatar of undefined
Last Comment
Whing Dela Cruz

8/22/2022 - Mon
Big Monty

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?
Big Monty

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:

<%
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
%>

Open in new window

Whing Dela Cruz

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!
Experts Exchange has (a) saved my job multiple times, (b) saved me hours, days, and even weeks of work, and often (c) makes me look like a superhero! This place is MAGIC!
Walt Forbes
Big Monty

can you post all of the code you have so far?
Whing Dela Cruz

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.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 & "'")
       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
%>
Big Monty

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
%>

Open in new window

⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.
Whing Dela Cruz

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
Big Monty

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
Big Monty

is this what you're looking to do?
Whing Dela Cruz

ASKER
Thanks a lot Monty, Its working..
I started with Experts Exchange in 2004 and it's been a mainstay of my professional computing life since. It helped me launch a career as a programmer / Oracle data analyst
William Peck