SqlDataReader SqlQuery(string query)
{
SqlConnection sqlConnection = new SqlConnection(@"Data Source=(LocalDB)\v11.0;AttachDbFilename=|DataDirectory|\mail.mdf;Integrated Security=True");
SqlCommand cmd = new SqlCommand();
SqlDataReader reader;
cmd.CommandText = query;
cmd.CommandType = CommandType.Text;
cmd.Connection = sqlConnection;
try
{
sqlConnection.Open();
}
catch { }
reader = cmd.ExecuteReader();
return reader;
}
try
{
sqlConnection.Open();
}
catch { }
try
{
sqlConnection.Open();
//Логика работы с данными.
}
catch { }
finally{
sqlConnection.Close();
}
try
{
sqlConnection.Open();
}
catch { }
using(SqlConnection sqlConnection = new SqlConnection(@"Data Source=(LocalDB)\v11.0;AttachDbFilename=|DataDirectory|\mail.mdf;Integrated Security=True"))
{
using(SqlCommand cmd = new SqlCommand())
{
}
}
catch { }
catch
{
throw;
}