- Jun 2, 2008
- 163
- 0
- 0
I'm working on a project and I have a question.
I and another person are working on it and we have decided to keep classes separate for organization.
So we have dbLoginAuth.cs and dbDataReader.cs classes, there will be more in the future.
They both need to connect to a database.
I'd like to have another class that has the connection string so we have a one stop area that if it needs to be changed, it's in one spot.
dbLoginAuth and dbDataReader have this.
SqlConnection con = null;
SqlCommand com = null;
SqlDataReader dr = null;
con = new SqlConnection(ConfigurationManager.ConnectionStrings["OWCDEMOConnectionString"].ConnectionString);
con.Open();
etc....
I want them to not have this but call it from another class, is that the right way to approach this? Or should I made like maybe a XML file to read from?
I and another person are working on it and we have decided to keep classes separate for organization.
So we have dbLoginAuth.cs and dbDataReader.cs classes, there will be more in the future.
They both need to connect to a database.
I'd like to have another class that has the connection string so we have a one stop area that if it needs to be changed, it's in one spot.
dbLoginAuth and dbDataReader have this.
SqlConnection con = null;
SqlCommand com = null;
SqlDataReader dr = null;
con = new SqlConnection(ConfigurationManager.ConnectionStrings["OWCDEMOConnectionString"].ConnectionString);
con.Open();
etc....
I want them to not have this but call it from another class, is that the right way to approach this? Or should I made like maybe a XML file to read from?