SqlConnection con = new SqlConnection("Data Source=.\\SQLEXPRESS;Initial Catalog=Your Database Name;Integrated Security=True");
con.Open();
SqlCommand command= new SqlCommand();
command.Connection = con;
command.CommandType = CommandType.Text;
command.CommandText = "your query here"
try
{
command.ExecuteNonQuery();
con.Close();
}
catch (Exception e)
{
}