473,386 Members | 1,860 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

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
Nov 18 '05 #1
2 1030
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" <ti********@nav-international.com> wrote in message
news:e5**************************@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

Nov 18 '05 #2
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" <ti********@nav-international.com> wrote in message
news:e5**************************@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

Nov 18 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: John Whitmer | last post by:
I am trying to put together a web page to show remote users which PC's are available for RDP so they can use. The page work's fine except for when the goes to the pc to pull the info on if anybody...
6
by: LaurenW | last post by:
After the "ExitHere" below, I am closing my object vars and setting their values to nothing. Am I doing it correctly? Thanks for all responses. '================= BEGIN CODE...
11
by: Bore Biko | last post by:
Dear, I have function that transform time from secconds to string formated as dd:hh:mm:ss (days:hours:minutes:seconds), but it doesent work correctly... Here s code compiled with gcc it goes...
5
by: Eric Renken | last post by:
OK, I have a form with a menu and a tool bar. In the Menu I have a File menu that contains a "Exit" item. When I click this Exit item. I have an event wired to: mnuFile.DropDown.ItemClicked ...
9
by: Wayne Smith | last post by:
I've come up against a major headache that I can't seem to find a solution for but I'm sure there must be a workaround and I would really be grateful of any help. I'm currently building a web...
8
by: Joshua Moore | last post by:
/* Hi, I was hoping someone could help me with this problem. I did my work and worked my way through the usual compiler messages, but I have run against some problem I can't identify. The compiler...
8
by: lovecreatesbea... | last post by:
Does this part of C code call and check strtol() correctly? port = strtol(argv, &endptr, 10); if (argv == endptr){ fprintf(stderr, "%s\n", "Invalid port number form"); return 1; } if (port ==...
2
by: necron99 | last post by:
import RuntimeEnvironment as renv import os, sys import win32com.client import getpass OMI = win32com.client.Dispatch("MOVEitAPI.clientObj") OMI.Host = system
7
by: jeddiki | last post by:
Hi, As I am in Turkey at present, I can not see vidoes on youtube. So I have tried a few proxies but keep finding them slow or not working. So I have installed myphpProxy on my server under...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.