• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 288
  • Last Modified:

using Where clause in the Command Object in c# for Winforms

I have following function,
public Customer GetCustomer(string customerName)
   string command = "select * from Customers where 'Name = customerName' ";
   OleDbDataAdapter da = new OleDbDataAdapter(command,connection);
   DataSet ds = new DataSet();
   DataTable dt = ds.Tables[0];
  if(dt.Rows.Count == 0)
       return null;
   return GetObject(dt.Rows[0]) as Customer;

but eventhough im passing the Name as parameter and using it in my where claues its getting the only first row of the table and not the desired row.
Can any one tell me where im going wrong.
1 Solution
"select * from Customers where Name = '" + customerName + "'";
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now