// Collection of code snippets by Arne Vajhøj // (likely posted to comp.os.vms/INFO-VAX, INFO-TPU, MACRO32, eksperten.dk, newz.dk, LinkedIn or other place sometime between 1990 and now) using System; using System.Data; using System.Data.SqlClient; namespace E { public class MainClass { public SqlDataReader GetReader(string connstr, string sqlstr) { SqlConnection con = new SqlConnection(connstr); con.Open(); SqlCommand cmd = new SqlCommand(sqlstr, con); return cmd.ExecuteReader(CommandBehavior.CloseConnection); } public DataSet GetDataSet(string connstr, string sqlstr) { SqlConnection con = new SqlConnection(connstr); con.Open(); SqlDataAdapter da = new SqlDataAdapter(sqlstr, con); DataSet ds = new DataSet(); da.Fill(ds); con.Close(); return ds; } public static void Main(string[] args) { } } }