I have the following code:
public DataTable GetAllActiveUsers() { DataTable dataTable = new DataTable(); try { connection.Open(); SqlCommand getAllActiveUsersCommand = new SqlCommand(getAllUsers, connection); SqlDataAdapter dataAdapter = new SqlDataAdapter(getAllActiveUsersCommand); dataAdapter.Fill(dataTable); return dataTable; } catch(Exception e) { Console.WriteLine(e); return null; } finally { connection.Close(); } }
Mostly I get active users in my database. But can someone explain to me whether the Finally block will execute if it successfully starts the try block and returns a DataTable ??
thanks
Danny source share