Skip to content

Instantly share code, notes, and snippets.

@kkurni
Created January 14, 2016 03:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kkurni/ebfeee14460f0ec7fb57 to your computer and use it in GitHub Desktop.
Save kkurni/ebfeee14460f0ec7fb57 to your computer and use it in GitHub Desktop.
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