G
Gustaf
Can a database connection be closed without calling the Close() method, like in this example:
using (OleDbConnection c = new OleDbConnection("..."))
{
try
{
// Open connection
c.Open();
}
catch (Exception ex)
{
// Report error
}
}
Or do I need something like:
try
{
// Open connection
OleDbConnection c = new OleDbConnection("...");
c.Open();
}
catch (Exception ex)
{
// Report error
}
finally
{
// Close connection
if (c != null)
c.Close();
}
Are these two equivalent?
Gustaf
using (OleDbConnection c = new OleDbConnection("..."))
{
try
{
// Open connection
c.Open();
}
catch (Exception ex)
{
// Report error
}
}
Or do I need something like:
try
{
// Open connection
OleDbConnection c = new OleDbConnection("...");
c.Open();
}
catch (Exception ex)
{
// Report error
}
finally
{
// Close connection
if (c != null)
c.Close();
}
Are these two equivalent?
Gustaf