C#: пример подключения к базе данных MSSQL
/*
* Created by SharpDevelop.
* http://kmsvsr.ru
* Date: 11.04.2015
* Time: 15:23
*/
using System;
using System.Data.SqlClient;
namespace ExecSQL
{
class Program
{
public static void Main(string[] args)
{
Console.WriteLine("Let`s execute our query!");
using (SqlConnection con = new SqlConnection("user id=sa;password=Pa$$w0rd;server=192.168.3.4;database=MyBase;connection timeout=30;"))
{
con.Open();
using (SqlCommand command = new SqlCommand("select COLUMN1 from MYTABLE where COLUMN2 ='http://kmsvsr.ru'", con))
using (SqlDataReader reader = command.ExecuteReader())
{
while (reader.Read())
{
//Console.WriteLine("{0} {1} {2}", reader.GetInt32(0), reader.GetString(1), reader.GetString(2));
Console.WriteLine("{0}", reader.GetInt32(0));
}
}
}
Console.Write("Press any key to exit . . . ");
Console.ReadKey(true);
}
}
}