> public DataTable GetAllData2(int DomainID) > { > string cnStr; > > cnStr = mmAppBase.DatabaseMgr.GetConnectionString("BinaDB"); > using (SqlConnection cn = new SqlConnection(cnStr)) > { > SqlCommand cmd = new SqlCommand("SELECT * FROM DomainRef WHERE DomainID = " + DomainID.ToString() , cn); > SqlDataAdapter adpt = new SqlDataAdapter(cmd); > DataTable dtStuff = new DataTable("stuff"); > adpt.Fill(dtStuff); > return dtStuff; > } > } >You should just create additional methods in your business object to get the data you want. GetAllData is only for when you litteraly want to Get All Data which shouldn't be that often.
/// Returns an Entity List public mmBindingList<DomainRefEntity> GetDomainRefByDomainID(int domainID) { mmBindingList<DomainRefEntity> domainRefList; domainRefList = this.GetEntityList("SELECT * FROM DomainRef WHERE DomainID = @DomainID", this.CreateParameter("@DomainID", domainID.ToString())); return domainRefList; }If you want to return a DataSet or DataTable you can do that by calling the proper method on the business object base class also.
public DataSet GetDomainRefByDomainID(int domainID) { return this.GetDataSet("SELECT * FROM DomainRef WHERE DomainID = @DomainID", this.CreateParameter("@DomainID", domainID.ToString())); }You do not need to create a connection and all that; the framework already does that for you much better.