Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

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?

Posted

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?

  • Administrators
Posted

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.

Posting Guidelines FAQ Post Formatting

 

Intellectuals solve problems; geniuses prevent them.

-- Albert Einstein

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...