Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Can someone help me get this sub to exit correctly?

Reply
Thread Tools

Can someone help me get this sub to exit correctly?

 
 
Teep
Guest
Posts: n/a
 
      06-25-2004
Where there is a duplicate invoice, I want to stop the process and
post to the user on the same page and not continue to the next
page...I tried Return or Exit Sub...but still the same thing occurs.

Sub Close1Open2(Source as Object, E as EventArgs)
pnl1.visible="false"
pnl2.visible="false"
pnl3.visible="false"
pnl4.visible="true"

Dim strConn as string =
"server=abcd;database=cds;trusted_connection=t rue"
Dim MySQL as string = "Select supplier_cd, inv_no, inv_date from
view_cds_all where supplier_cd='" & txtSupCD.text & "' and inv_no='" &
txtInvNum.text & "' and inv_date='" & txtInvDate.text & "'"
Dim MyConn as New SQLConnection(strConn)
Dim objDR as SQLDataReader
Dim Cmd as New SQLCommand(MySQL, MyConn)
MyConn.Open()
objDR=Cmd.ExecuteReader()
While objDR.Read()
If IsDbNull(objDR.GetString(0))=False Then
blHasRows="True"
else
blHasRows="False"
End If
End While
MyConn.Close()

MySQL = "Insert into a_p.dbo.tbl_ap_web_ce_inv_terms (splr_cd,
inv_numb, inv_dat) Values ('" & txtSupCD.text & "','" & txtInvNum.text
& "'," & txtInvDate.text & ")"
Dim Cmd2 as New SQLCommand(MySQL, MyConn)
if blHasRows="False" then
MyConn.Open()
Cmd2.ExecuteNonQuery()
lblResults.text="Your information has been received!"
MyConn.Close
else
lblResults.text="Sorry, that information is already in the
database"
End If
End Sub
 
Reply With Quote
 
 
 
 
Rick Spiewak
Guest
Posts: n/a
 
      06-27-2004
You aren't showing the code that redirects to the next page, which is where
you would need to detect and act on the difference. If you're calling this
sub from that code, try making it a function and return a boolean indicating
whether to continue or not.

"Teep" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed) om...
> Where there is a duplicate invoice, I want to stop the process and
> post to the user on the same page and not continue to the next
> page...I tried Return or Exit Sub...but still the same thing occurs.
>
> Sub Close1Open2(Source as Object, E as EventArgs)
> pnl1.visible="false"
> pnl2.visible="false"
> pnl3.visible="false"
> pnl4.visible="true"
>
> Dim strConn as string =
> "server=abcd;database=cds;trusted_connection=t rue"
> Dim MySQL as string = "Select supplier_cd, inv_no, inv_date from
> view_cds_all where supplier_cd='" & txtSupCD.text & "' and inv_no='" &
> txtInvNum.text & "' and inv_date='" & txtInvDate.text & "'"
> Dim MyConn as New SQLConnection(strConn)
> Dim objDR as SQLDataReader
> Dim Cmd as New SQLCommand(MySQL, MyConn)
> MyConn.Open()
> objDR=Cmd.ExecuteReader()
> While objDR.Read()
> If IsDbNull(objDR.GetString(0))=False Then
> blHasRows="True"
> else
> blHasRows="False"
> End If
> End While
> MyConn.Close()
>
> MySQL = "Insert into a_p.dbo.tbl_ap_web_ce_inv_terms (splr_cd,
> inv_numb, inv_dat) Values ('" & txtSupCD.text & "','" & txtInvNum.text
> & "'," & txtInvDate.text & ")"
> Dim Cmd2 as New SQLCommand(MySQL, MyConn)
> if blHasRows="False" then
> MyConn.Open()
> Cmd2.ExecuteNonQuery()
> lblResults.text="Your information has been received!"
> MyConn.Close
> else
> lblResults.text="Sorry, that information is already in the
> database"
> End If
> End Sub



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Death To Sub-Sub-Sub-Directories! Lawrence D'Oliveiro Java 92 05-20-2011 06:50 AM
I don't get why sys.exit(1) doesn't exit the while loop in the follow case chad Python 14 10-13-2010 09:08 AM
Recognising Sub-Items and sub-sub items using xslt Ben XML 2 09-19-2007 09:35 AM
Can I get the exit code "n" passed to sys.exit(n) ? Yujo Python 2 04-10-2007 08:35 PM
Code to Exit Web App and Exit Internet Explorer =?Utf-8?B?U2FuZHk=?= ASP .Net 7 08-05-2005 01:55 AM



Advertisments