Solved

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

Posted on 2007-04-05
3
232 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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Today I had a very interesting conundrum that had to get solved quickly. Needless to say, it wasn't resolved quickly because when we needed it we were very rushed, but as soon as the conference call was over and I took a step back I saw the correct …
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!
This video discusses moving either the default database or any database to a new volume.
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…

744 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now