public class SQLHelp
{
private SqlConnection conn=null;
private string ConnStr=" server=.;dataBase=BookShop;uid=sa;pwd=;";
public bool OpenConnection()
{
if(conn==null)
conn=new SqlConnection(ConnStr);
try{
conn.Open();
return true;
}
catch(Exception)
{
return false;
}
public void CloseConnection(){
conn.Close();
conn.Dispose();
}
public SqlDataReader ExecReader(string sqlQuery,CommandType type=CommandType.Text,SqlParameter[] parms=null)
SqlCommand cm=new SqlCommand();
cm.CommandText=sqlQuery;
cm.Connection=conn;
cm.CommandType=type;
if(parms!=null)
cm.Parameters.AddRange(parms);
try{
SqlDataReader dr=cm.ExecuteReader();
return dr;
}
catch(Exception)
return null;
}
public int ExecQuery(){
}
public object ExecScalar(){
}
}