Wednesday, 12 December 2012

Test SQL Server connection use C#

Solutions:   
 
SqlConnection oConnection = new SqlConnection("user id='Usename';password='Password ';Data Source='Sql servername ';Trusted_Connection=yes;");
            try
            {
                oConnection.Open();
                Messagebox("SQL connection test successfully");
             }
            catch (Exception test)
            {
                Messagebox("SQL connection problem");
            }
            finally
            {
                oConnection.Close();
            } 

No comments:

Post a Comment