Solved

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

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Combine two datatables into one based on a value from second datatable 4 33
Tool Box 2 35
Replace &lt; with < 14 56
Javascript and Jquery not firing 9 42
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
Windows 10 is mostly good. However the one thing that annoys me is how many clicks you have to do to dial a VPN connection. You have to go to settings from the start menu, (2 clicks), Network and Internet (1 click), Click VPN (another click) then fi…
Internet Business Fax to Email Made Easy - With  eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, f…

896 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

14 Experts available now in Live!

Get 1:1 Help Now