There is a database connection code and a request to it -
SqlConnection SqlConnection; public async void connectDB() { string ConnectionAdres = @"Путь"; SqlConnection = new SqlConnection(ConnectionAdres); await SqlConnection.OpenAsync(); SqlDataReader SQLDReader = null; SqlCommand GetAllEmployCommand = new SqlCommand("SELECT * FROM [employment]", SqlConnection); try { SQLDReader = await GetAllEmployCommand.ExecuteReaderAsync(); while (await SQLDReader.ReadAsync()) { string test = Convert.ToString(SQLDReader["ID"]) + Convert.ToString(SQLDReader["surname"]) + Convert.ToString(SQLDReader["name"]) + Convert.ToString(SQLDReader["patronymic"]); } } catch (Exception ex) { } finally { if (SQLDReader != null) { SQLDReader.Close(); } } public void closeConnect() { if (SqlConnection != null && SqlConnection.State != ConnectionState.Closed) { SqlConnection.Close(); } } How can I separate the connection and requests? And is it normal if the connection will be open throughout the program? I click on the button-> from the beginning the connection method is called, then the request. Or to write each request in the code as I have is a normal practice?