Answers for "how to check database connection in sql server"

SQL
1

how to check connection with sql server in c#

/// <summary>
/// Test that the server is connected
/// </summary>
/// <param name="connectionString">The connection string</param>
/// <returns>true if the connection is opened</returns>
private static bool IsServerConnected(string connectionString)
{
    using (SqlConnection connection = new SqlConnection(connectionString))
    {
        try
        {
            connection.Open();
            return true;
        }
        catch (SqlException)
        {
            return false;
        }
    }
}
Posted by: Guest on September-21-2021
1

show sql server database

EXEC sp_databases
Posted by: Guest on October-30-2020

Code answers related to "how to check database connection in sql server"

Code answers related to "SQL"

Browse Popular Code Answers by Language