Hello. This may be a dumb question, but it's driving me crazy. The
function is supposed to to fill a datatable. It works just fine, but I'm
testing to make sure my error handling works so I changed the name of the
stored procedure so I know I will get an error. However, for some reason,
my try/catch does not catch the error. Instead, the program seems to stop.
Does this make sense? Do you have any ideas why this happens?

Thank you!



Protected sub Run(ByVal sprocName As String, ByVal parameters() As
SqlParameter, ByRef dataTable As DataTable)

Dim command As SqlCommand

command = CreateCommand(sprocName, parameters)

Dim dataAdapter As SqlDataAdapter

dataTable = New DataTable

dataAdapter = New SqlDataAdapter

dataAdapter.SelectCommand = command

dataAdapter.Fill(dataTable)

End Function

Re: testing try/catch when filling a data adapter by Jon

Jon
Fri Jul 23 08:14:37 CDT 2004

SteveS <ssinger@trendmls.com> wrote:
> Hello. This may be a dumb question, but it's driving me crazy. The
> function is supposed to to fill a datatable. It works just fine, but I'm
> testing to make sure my error handling works so I changed the name of the
> stored procedure so I know I will get an error. However, for some reason,
> my try/catch does not catch the error. Instead, the program seems to stop.
> Does this make sense? Do you have any ideas why this happens?
>
> Protected sub Run(ByVal sprocName As String, ByVal parameters() As
> SqlParameter, ByRef dataTable As DataTable)
>
> Dim command As SqlCommand
> command = CreateCommand(sprocName, parameters)
> Dim dataAdapter As SqlDataAdapter
> dataTable = New DataTable
> dataAdapter = New SqlDataAdapter
> dataAdapter.SelectCommand = command
> dataAdapter.Fill(dataTable)
> End Function

Well for one thing, you haven't shown a try/catch in there...

--
Jon Skeet - <skeet@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too

Re: testing try/catch when filling a data adapter by Cor

Cor
Fri Jul 23 10:44:14 CDT 2004


"Jon Skeet [C# MVP]" <skeet@pobox.com> schreef in bericht > End Function
>
> Well for one thing, you haven't shown a try/catch in there...
>
LOL

Cor