Created
January 14, 2016 03:14
-
-
Save kkurni/ebfeee14460f0ec7fb57 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Data; | |
using System.Data.SqlClient; | |
public class Program | |
{ | |
public static void Main() | |
{ | |
Console.WriteLine("Run"); | |
TestConnectionString("your connection string"); | |
} | |
public static void TestConnectionString(string connstr) | |
{ | |
using (var conn = new SqlConnection(connstr)) | |
{ | |
Console.WriteLine("BEFORE CONN OPEN : {0}. Press any key to continue.", connstr); | |
Console.ReadLine(); | |
conn.Open(); | |
Console.WriteLine("AFTER CONN OPEN. Press any key to continue."); | |
Console.ReadLine(); | |
Console.WriteLine("create command..."); | |
var cmd = new SqlCommand("select @@Version", conn); | |
Console.WriteLine("Execute reader..."); | |
using (var reader = cmd.ExecuteReader()) | |
{ | |
Console.WriteLine("read..."); | |
while (reader.Read()) | |
{ | |
Console.WriteLine(reader.GetString(0)); | |
} | |
} | |
} | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment