如何继续例外 [英] How to continue on Exception
问题描述
在此先感谢,
是否可以在异常(SQL错误)上继续执行过程,如它将执行下一条语句,在错误继续执行上一样,我正在从.net应用程序中运行SQL脚本,希望它将继续执行脚本,因此我正在使用 Microsoft.SqlServer.Smo.dll 用于执行脚本.
我的问题与Try Catch无关.例如,如果我的SQL文件中有10条SQL语句,则在执行
时第二行出现错误
server.ConnectionContext.ExecuteNonQuery(Script.sql)
然后它将继续执行,例如,它将转到下一行,即第三行.
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.
推荐答案
处理异常将使您能够继续执行(基于如何您可以处理异常).
看看try-catch
块 [ ^ ].
Handling the exception will allow you to continue (based on how you handle the exception).
Have a look at thetry-catch
block[^].
使用如下所示的try catch块:
Hi,
Use a try catch block like this:
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
这篇关于如何继续例外的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!