M
M
Hi,
Does SqlDataAdapter always close the connection (assuming connection was
closed before calling Fill()), even if an exception occurs while calling
Fill()?
Example:
try
{
myDataAdapter.Fill(myDataTable);
}
catch
{
// display some error message or something
}
or should I do this instead
try
{
myDataAdapter.Fill(myDataTable);
}
catch
{
// display some error message or something
}
finally
{
if (conn.State == ConnectionState.Open)
{
conn.Close();
}
}
Thanks.
Does SqlDataAdapter always close the connection (assuming connection was
closed before calling Fill()), even if an exception occurs while calling
Fill()?
Example:
try
{
myDataAdapter.Fill(myDataTable);
}
catch
{
// display some error message or something
}
or should I do this instead
try
{
myDataAdapter.Fill(myDataTable);
}
catch
{
// display some error message or something
}
finally
{
if (conn.State == ConnectionState.Open)
{
conn.Close();
}
}
Thanks.