Link to home
Start Free TrialLog in
Avatar of Whing Dela Cruz
Whing Dela CruzFlag 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
%>
Avatar of Big Monty
Big Monty
Flag of United States of America image

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:

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

Avatar of 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!
can you post all of the code you have so far?
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
%>
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

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
Avatar of Big Monty
Big Monty
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
is this what you're looking to do?
Thanks a lot Monty, Its working..