Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

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

Posted on 2007-04-05
3
259 Views
Last Modified: 2010-05-18
Hi,
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();
   da.Fill(ds,"Customers");
   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.
Thanks
0
Comment
Question by:aspnetdev
3 Comments
 
LVL 10

Accepted Solution

by:
ksaul earned 125 total points
ID: 18858067
"select * from Customers where Name = '" + customerName + "'";
0

Featured Post

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Wouldn’t it be nice if you could test whether an element is contained in an array by using a Contains method just like the one available on List objects? Wouldn’t it be good if you could write code like this? (CODE) In .NET 3.5, this is possible…
Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

809 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question