Windows Vista Forums
Vista Forums Home Join Vista Forums Windows 7 Forum Vista Tutorials Tags
Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks.

Go Back   Vista Forums > Misc Newsgroups > .NET General

Vista - continue execution after try/catch

Reply
 
Old 08-22-2008   #1 (permalink)
E. Kwong


 
 

continue execution after try/catch

I have a For loop to insert record to a SQL server database, like:


For Each item As ListItem In cblxyz.Items
If (item.Selected) Then
.... do something
Try
srcxyz.Insert()
Catch SQLExp As SqlException
....display error
End Try
End If
Next



Now when a duplicate record is encountered, it displays the error and then
stops. I need the loop to go on after displaying the database error. Is
there any way to do that? Or do I have to check whether the record is
already existing in the database every single time before doing the Insert?



Any insight appreciated.



I'm using VS2005, SQL Server 2000, .Net 2.0






My System SpecsSystem Spec
Old 08-23-2008   #2 (permalink)
Jack Jackson


 
 

Re: continue execution after try/catch

What do you mean by "it stops".

If the Catch doesn't do anything to cause execution to go anywhere
else, execution should resume after the End Try.

Set a breakpoint on the Catch and step it to see what happens.

On Fri, 22 Aug 2008 17:45:58 -0700, "E. Kwong"
<ekwong999AThotmail.com> wrote:
Quote:

>I have a For loop to insert record to a SQL server database, like:
>
>
>For Each item As ListItem In cblxyz.Items
>If (item.Selected) Then
>... do something
>Try
> srcxyz.Insert()
>Catch SQLExp As SqlException
> ....display error
>End Try
>End If
>Next
>
>
>
>Now when a duplicate record is encountered, it displays the error and then
>stops. I need the loop to go on after displaying the database error. Is
>there any way to do that? Or do I have to check whether the record is
>already existing in the database every single time before doing the Insert?
>
>
>
>Any insight appreciated.
>
>
>
>I'm using VS2005, SQL Server 2000, .Net 2.0
>
>
>
>
My System SpecsSystem Spec
Old 08-23-2008   #3 (permalink)
PvdG42


 
 

Re: continue execution after try/catch

"E. Kwong" <ekwong999AThotmail.com> wrote in message
news:%23BE6cmLBJHA.5964@xxxxxx
Quote:

>I have a For loop to insert record to a SQL server database, like:
>
>
> For Each item As ListItem In cblxyz.Items
> If (item.Selected) Then
> ... do something
> Try
> srcxyz.Insert()
> Catch SQLExp As SqlException
> ....display error
> End Try
> End If
> Next
>
>
>
> Now when a duplicate record is encountered, it displays the error and then
> stops. I need the loop to go on after displaying the database error.
> Is there any way to do that? Or do I have to check whether the record is
> already existing in the database every single time before doing the
> Insert?
>
>
>
> Any insight appreciated.
>
>
>
> I'm using VS2005, SQL Server 2000, .Net 2.0
>
How do you "display error"? In a message box, by any chance?

My System SpecsSystem Spec
Old 08-25-2008   #4 (permalink)
E. Kwong


 
 

Re: continue execution after try/catch

Thanks Jack Jackson and PvdG42.

It turns out that I did not get the correct checkboxlist value to create the
record.


"PvdG42" <pvdg@xxxxxx> wrote in message
news:uB6gcATBJHA.3888@xxxxxx
Quote:

> "E. Kwong" <ekwong999AThotmail.com> wrote in message
> news:%23BE6cmLBJHA.5964@xxxxxx
Quote:

>>I have a For loop to insert record to a SQL server database, like:
>>
>>
>> For Each item As ListItem In cblxyz.Items
>> If (item.Selected) Then
>> ... do something
>> Try
>> srcxyz.Insert()
>> Catch SQLExp As SqlException
>> ....display error
>> End Try
>> End If
>> Next
>>
>>
>>
>> Now when a duplicate record is encountered, it displays the error and
>> then stops. I need the loop to go on after displaying the database
>> error. Is there any way to do that? Or do I have to check whether the
>> record is already existing in the database every single time before doing
>> the Insert?
>>
>>
>>
>> Any insight appreciated.
>>
>>
>>
>> I'm using VS2005, SQL Server 2000, .Net 2.0
>>
> How do you "display error"? In a message box, by any chance?
>

My System SpecsSystem Spec
Reply

Thread Tools


Similar Threads
Thread Forum
Try Catch .NET General
catch-up Vista mail
Catch-all PowerShell
How to TRY and CATCH PowerShell
I Catch VI Vista hardware & devices


Vista Forums is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media Ltd

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46