Click here to Skip to main content
15,914,220 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Thanks in advance,

Is it possible to continue process on exception (SQL Error) , like it will execute next statement, something like on error resume next , I am running SQL Script from .net application , wants that it will continue executing script, I am using Microsoft.SqlServer.Smo.dll for executing script.


My Qustion is not regarding Try Catch.Its like, if i have 10 SQL statements on my SQL file, then ,if error comes on second line while executing

server.ConnectionContext.ExecuteNonQuery(Script.sql)

then it will continue its execution, for example, it will go to the next line which is third.
Posted
Updated 21-May-12 23:42pm
v3

Handling the exception will allow you to continue (based on how you handle the exception).

Have a look at the try-catch block[^].
 
Share this answer
 
Hi,

Use a try catch block like this:


VB
Sub Main()
        Dim i As Integer
        Dim var() As Integer
        var = New Integer() {1, 2, 3, 4, 5}


        For Each i In var

            Try
                Console.WriteLine(i.ToString())
            Catch ex As Exception
                Continue For
            End Try

        Next

    End Sub
 
Share this answer
 
Comments
εїзεїзεїз 22-May-12 5:44am    
thanks for reply , I think so ,my question was not much clearer, Its regarding executing next SQL statement.
Sunny_Kumar_ 22-May-12 6:04am    
please share the piece of code what you've tried yet to get a clear picture of the context

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900