Solved

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

Posted on 2007-04-05
3
266 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 our DevOps Teams Maximize Uptime

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us. Read the use case whitepaper.

Question has a verified solution.

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

Suggested Solutions

For those of you who don't follow the news, or just happen to live under rocks, Microsoft Research released a beta SDK (http://www.microsoft.com/en-us/download/details.aspx?id=27876) for the Xbox 360 Kinect. If you don't know what a Kinect is (http:…
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!
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…
Attackers love to prey on accounts that have privileges. Reducing privileged accounts and protecting privileged accounts therefore is paramount. Users, groups, and service accounts need to be protected to help protect the entire Active Directory …

679 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