Hi,
I'm trying to write a generic base class to loop through data and fill my collection objects.
The thing is that the base class doesn't know the type of the object I guess.
The code should look something like this....
--------------------------------------------------------------------------------------
public class baseCollection : System.Collections.CollectionBase
{
protected void Fill(string strSQL)
{
SqlConnection Conn = new SqlConnection("conn settings");
Conn.Open();
SqlCommand cmdContent = new SqlCommand("strSQL", Conn);
SqlDataReader drContent;
drContent = cmdContent.ExecuteReader();
while (drContent.Read())
{
// add the specific item to this collection
}
drContent.Close();
Conn.Close();
}
}
public class Employers : baseCollection
{
Fill("select * from tblEmployer")
}
public class Shops : baseCollection
{
Fill("select * from tblShop")
}
--------------------------------------------------------------------------------------
anyone?