Solved

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

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

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

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

Many of us here at EE write code. Many of us write exceptional code; just as many of us write exception-prone code. As we all should know, exceptions are a mechanism for handling errors which are typically out of our control. From database errors, t…
This article is for Object-Oriented Programming (OOP) beginners. An Interface contains declarations of events, indexers, methods and/or properties. Any class which implements the Interface should provide the concrete implementation for each Inter…
This is used to tweak the memory usage for your computer, it is used for servers more so than workstations but just be careful editing registry settings as it may cause irreversible results. I hold no responsibility for anything you do to the regist…
In a recent question (https://www.experts-exchange.com/questions/28997919/Pagination-in-Adobe-Acrobat.html) here at Experts Exchange, a member asked how to add page numbers to a PDF file using Adobe Acrobat XI Pro. This short video Micro Tutorial sh…

816 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