// :::::::::::: Use this method to execute query by DataReader :::::::::::: public static SqlDataReader getDataReader(string MyQuery) { SqlConnection con = new SqlConnection(); dbConnection dbCon = new dbConnection(); con = dbCon.dbConnect(); con.Open(); SqlCommand cmd = new SqlCommand(MyQuery, con); return(cmd.ExecuteReader()); }
// :::::::::::: Use this method to return a DataSet from query string :::::::::::: public DataSet getDataSet(string MyQuery, string MyString) { SqlConnection con = new SqlConnection(); dbConnection dbCon = new dbConnection(); SqlDataAdapter daGen; DataSet dsGen; dsGen = new DataSet(); con = dbCon.dbConnect(); daGen = new SqlDataAdapter(MyQuery, con); daGen.Fill(dsGen, MyString); return(dsGen); }
public static DataTable getResultStringConvert(string MyQuery) { DataTable dt = new DataTable(); SqlConnection con1 = new SqlConnection(); dbConnection dbCon1 = new dbConnection(); SqlDataAdapter daGen1; DataSet dsGen1; dsGen1 = new DataSet(); con1 = dbCon1.dbConnect(); daGen1 = new SqlDataAdapter(MyQuery, con1); daGen1.Fill(dsGen1); dt = dsGen1.Tables[0]; return(dt); }
// :::::::::::: Use this method to return a DataTable from query string :::::::::::: public DataTable getDataTable(string MyQuery, string MyTable) { DataTable dt = new DataTable(); SqlConnection con1 = new SqlConnection(); dbConnection dbCon1 = new dbConnection(); SqlDataAdapter daGen1; DataSet dsGen1; dsGen1 = new DataSet(); con1 = dbCon1.dbConnect(); daGen1 = new SqlDataAdapter(MyQuery, con1); daGen1.Fill(dsGen1, MyTable); dt = dsGen1.Tables[MyTable]; dsGen1.Tables.Remove(MyTable); return(dt); }