Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   ASP .Net (http://www.velocityreviews.com/forums/f29-asp-net.html)
-   -   Can someone help me get this sub to exit correctly? (http://www.velocityreviews.com/forums/t81430-can-someone-help-me-get-this-sub-to-exit-correctly.html)

Teep 06-25-2004 10:13 PM

Can someone help me get this sub to exit correctly?
 
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

Rick Spiewak 06-27-2004 03:27 AM

Re: Can someone help me get this sub to exit correctly?
 
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" <tina.pardi@nav-international.com> wrote in message
news:e55e9217.0406251413.3124435d@posting.google.c 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





All times are GMT. The time now is 01:29 PM.

Powered by vBulletin®. Copyright ©2000 - 2013, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.