Why can't i find a row in a dataset?

  • Thread starter Thread starter Paul Custance
  • Start date Start date
P

Paul Custance

Hi,

Currently had a Dataset that has information from the Northwind database, Customers table in it.

I have created my update and select commands and they work fine.

When I go to update a row in the data set I use this

//Get the datarow to edit
DataRow[] adrEdit = ds.Tables["Customers"].Select("CustomerID = 'txtCustomerID.Text'");

However this returns nothing, but if I do it explicitly like this

//Get the datarow to edit
DataRow[] adrEdit = ds.Tables["Customers"].Select("CustomerID = 'ALFKI'");

It works fine, why when I enter ALFKI in txtCustomerID.Text is it not making a match in the Dataset?

any help appreciated

Paul Custance
 
See below

Paul Custance said:
Hi,

Currently had a Dataset that has information from the Northwind database,
Customers table in it.

I have created my update and select commands and they work fine.

When I go to update a row in the data set I use this

//Get the datarow to edit
DataRow[] adrEdit = ds.Tables["Customers"].Select("CustomerID =
'txtCustomerID.Text'");

- Replace with

DataRow[] adrEdit = ds.Tables["Customers"].Select("CustomerID = '" +
txtCustomerID.Text + "'");

However this returns nothing, but if I do it explicitly like this

//Get the datarow to edit
DataRow[] adrEdit = ds.Tables["Customers"].Select("CustomerID = 'ALFKI'");

It works fine, why when I enter ALFKI in txtCustomerID.Text is it not
making a match in the Dataset?

any help appreciated

Paul Custance
 
you need to concatenate the string
select('customerid = '" + txtCustomerID.Text + "' ...

--
Regards,
Alvin Bruney
[Shameless Author Plug]
The Microsoft Office Web Components Black Book with .NET
available at www.lulu.com/owc
_________________________
 
OK I feel like a total idiot now, I stared at it that long that I couldn't see that I had made such a silly mistake!

Cheers VJ much appreciated

Paul Custance
See below

Hi,

Currently had a Dataset that has information from the Northwind database,
Customers table in it.

I have created my update and select commands and they work fine.

When I go to update a row in the data set I use this

//Get the datarow to edit
DataRow[] adrEdit = ds.Tables["Customers"].Select("CustomerID =
'txtCustomerID.Text'");


- Replace with

DataRow[] adrEdit = ds.Tables["Customers"].Select("CustomerID = '" +
txtCustomerID.Text + "'");


However this returns nothing, but if I do it explicitly like this

//Get the datarow to edit
DataRow[] adrEdit = ds.Tables["Customers"].Select("CustomerID = 'ALFKI'");

It works fine, why when I enter ALFKI in txtCustomerID.Text is it not
making a match in the Dataset?

any help appreciated

Paul Custance
 
Back
Top