Class code
using System; using System.Data; using System.Data.SqlClient; namespace exchange {public class MyDataOp {private String StrSql; private String StrConn; private SqlConnection Conn; public MyDataOp (String ss) {StrSql = ss; StrConn = System.Configuration .ConfigurationSettings.AppSettings [ "ConnectionString"];} public SqlDataReader CreateReader () {Conn = new SqlConnection (strConn); SqlCommand Comm = new SqlCommand (strSql, Conn); Conn.Open (); SqlDataReader MyReader = Comm.ExecuteReader () ; return MyReader;} public DataSet CreateDataSet () {Conn = new SqlConnection (strConn); Conn.Open (); SqlDataAdapter Adpt = new SqlDataAdapter (strSql, Conn); DataSet Ds = new DataSet (); Adpt.Fill (Ds) ; return Ds;} public SqlCommand ExecuteCommand () {Conn = new SqlConnection (strConn); SqlCommand Comm = new SqlCommand (strSql, Conn); Conn.Open (); Comm.ExecuteNonQuery (); return Comm;} public void Close ( ) {Conn.close ();}}}