Morpheus Posted November 9, 2003 Posted November 9, 2003 I have a method for searching a db: public virtual ArrayList Search(string parameter, string columnName) { ArrayList al = new ArrayList(); myCommand = MyConnection.CreateCommand(); myCommand.CommandText = "SELECT * FROM Customer WHERE" +columnName+ "= '" + parameter + "'"; myReader = myCommand.ExecuteReader(); while(myReader.Read()) { al.Add(myReader); } return al; } How can I use the override to just change the connectionstring? Quote
Administrators PlausiblyDamp Posted November 9, 2003 Administrators Posted November 9, 2003 Where is the connection string defined? You would probably be better off making the connection string a property of the class rather than using an override in this way. Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
Morpheus Posted November 9, 2003 Author Posted November 9, 2003 Sorry I meant the SQL-statement. That class is a base class for GetCustomers and GetSuppliers thought it would be the most logical way to handle requests for customers and suppliers. But maybe its better to handle both customers and suppliers in the same class? Quote
Administrators PlausiblyDamp Posted November 9, 2003 Administrators Posted November 9, 2003 If they could both be handled in the same class then that could be a cleaner solution. An alternative approach could be to define an interface for the Search method etc and have both the customers and suppliers classes implement it. Each would then have it's own code internal to the class but would expose a common interface for other functions to work with. Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
Morpheus Posted November 9, 2003 Author Posted November 9, 2003 Yeah that might be the solution. Thanks! Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.