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)))
{
try
{
conn.Open();
isOpened = (conn.State == ConnectionState.Open);
conn.Dispose();
}
catch (Exception e)
{
MessageBox.Show(e.Message);
throw;
}
finally
{
if (conn != null) {conn.Close();}
}


}
return isOpened;

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

  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.

  6. It’s truly very complex in this active life to
    listen news on TV, so I simply use world wide web for that purpose, and obtain the hottest news.
    ps4 games allenferguson ps4 games

  7. Excellent blog! Do you have any hints for aspiring writers?
    I’m planning to start my own blog soon but I’m
    a little lost on everything. Would you suggest starting with a free platform like WordPress or go for a paid option? There are
    so many choices out there that I’m completely overwhelmed ..
    Any suggestions? Thanks!

  8. Hmm it looks like your blog ate my first comment (it was extremely long) so I guess I’ll just sum it up what
    I had written and say, I’m thoroughly enjoying your blog.

    I as well am an aspiring blog writer but I’m still new to everything.
    Do you have any helpful hints for beginner blog writers?
    I’d really appreciate it. asmr 0mniartist

  9. Hi, I do think this is an excellent web site. I stumbledupon it 😉
    I’m going to come back once again since I bookmarked it. Money and
    freedom is the best way to change, may you be rich and continue to guide other
    people.

  10. Hi there! Do you know if they make any plugins
    to help with Search Engine Optimization? I’m trying to get my blog to rank for some targeted
    keywords but I’m not seeing very good success. If you know of any please share.
    Thank you!

  11. Hi! Someone in my Facebook group shared this website with us so I came to take
    a look. I’m definitely loving the information. I’m bookmarking and will be tweeting this to my
    followers! Exceptional blog and brilliant style
    and design.

  12. Hiya! Quick question that’s entirely off topic.
    Do you know how to make your site mobile friendly? My weblog looks weird when browsing from my
    iphone. I’m trying to find a template or plugin that might be able to
    correct this problem. If you have any suggestions, please share.
    Many thanks!

  13. Thanks for the sensible critique. Me & my neighbor were just preparing to do some research on this. We got a grab a book from our area library but I think I learned more from this post. I’m very glad to see such excellent info being shared freely out there.

  14. Its such as you learn my mind! You seem to understand
    a lot about this, like you wrote the book in it or something.
    I think that you simply could do with some p.c.
    to drive the message house a bit, but other than that, this is wonderful blog.
    An excellent read. I’ll certainly be back.

  15. I was wondering if you ever considered changing the layout of your website?
    Its very well written; I love what youve got to say.
    But maybe you could a little more in the way of content so people
    could connect with it better. Youve got an awful lot of text for only having 1 or two images.
    Maybe you could space it out better?

  16. My spouse and I stumbled over here coming from a different web
    address and thought I may as well check things out.
    I like what I see so i am just following you. Look forward to
    finding out about your web page again.

답글 남기기