public DataSet GetDataSet(string strSql, Parameters parameter) { this.OpenConnection(); DataSet objDataSet = new DataSet(); try { SqlCommand comm = new SqlCommand(strSql, objConnection); foreach (DictionaryEntry obj in parameter.List) { ParameterString pstring = (ParameterString)obj.Value; comm.Parameters.AddWithValue(pstring.Parameter, pstring.Value); } SqlDataAdapter objAdapter = new SqlDataAdapter(comm); objAdapter.Fill(objDataSet); } catch (System.Data.SqlClient.SqlException objErr) { strErr = "[Err Source:]" + objErr.Source + "[Err Description:]" + objErr.Message.Replace("\n", "").Replace("\r", ""); } finally { this.CloseConnection(); } return objDataSet; }
public string GetCountResult(string strSql, Parameters parameter) { this.OpenConnection(); string result = "0"; try { SqlCommand comm = new SqlCommand(strSql, objConnection); foreach (DictionaryEntry obj in parameter.List) { ParameterString pstring = (ParameterString)obj.Value; comm.Parameters.AddWithValue(pstring.Parameter, pstring.Value); } SqlDataReader sdr = comm.ExecuteReader(CommandBehavior.SingleResult); if (sdr.Read()) { result = sdr["result"].ToString(); } sdr.Close(); } catch (System.Data.SqlClient.SqlException objErr) { strErr = "[Err Source:]" + objErr.Source + "[Err Description:]" + objErr.Message.Replace("\n", "").Replace("\r", ""); } finally { this.CloseConnection(); } return result; }