C# MS-SQL 연결확인

SQL 연결확인 하기
SQL Database에 연결이 정상적으로 되는지 확인하는 코드는 다음과 같다. SQL Server에 계정과 비밀번호로 접속하고 연결이 되는지 확인한다.
ServerName은 server IP 가 될수 도 있다. SQL EXPRESS의 경우는 “MY-PC\SQLEXPRESS”와 같이 사용한다.
Data Source=local ;Integrated Security = SSPI 등과 같이 사용하면 SQL 연결상태를 확인를 확인한다.
Integrated Security = SSPI를 삭제하면 계정의 접근여부 까지 확인 할 수 있다

bool isOpened = false;
using (SqlConnection conn = new SqlConnection(string.Format(@"Data Source ={0}; User ID = {1}; Password = {2}", ServerName, UserID, Password)))
isOpened = (conn.State == ConnectionState.Open);
catch (Exception e)
if (conn != null) {conn.Close();}

return isOpened;

“C# MS-SQL 연결확인”의 8개의 댓글

  1. Hello! I just wanted to ask if you ever have any problems with hackers?
    My last blog (wordpress) was hacked and I ended up losing many
    months of hard work due to no backup. Do you have any methods to
    stop hackers?

  2. Have you ever thought about publishing an e-book or guest authoring on other websites?
    I have a blog centered on the same subjects you discuss and would really like to have
    you share some stories/information. I know my audience would appreciate your work.
    If you are even remotely interested, feel free to send me an email.

  3. Hello! I know this is kinda off topic but I was wondering which blog platform are you using for this website?
    I’m getting tired of WordPress because I’ve had problems with hackers
    and I’m looking at options for another platform. I would be great if you could point
    me in the direction of a good platform.

  4. Wonderful paintings! This is the type of information that are supposed to be shared across the internet. Disgrace on Google for now not positioning this put up higher! Come on over and seek advice from my website . Thanks =)

  5. Hey there! Someone in my Facebook group shared this website with us so I came to take a look.

    I’m definitely enjoying the information. I’m book-marking and will be tweeting this
    to my followers! Terrific blog and wonderful design and style.

답글 남기기