using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Data.SqlClient; using System.Configuration; using System.Data; namespace mysite { public class DatabaseQuery { public static SqlDataReader Select(string sql) { SqlConnection conn = null; SqlCommand cmd = null; try { conn = new SqlConnection(ConfigurationManager.ConnectionStrings["mysiteConnectionString"].ConnectionString); conn.Open(); cmd = new SqlCommand(); cmd.Connection = conn; cmd.CommandText = sql; var res = cmd.ExecuteReader(CommandBehavior.CloseConnection); return res; } catch (System.Exception ex) { throw ex; } finally { cmd.Dispose(); } } } }