.NET 2.0
>
I'm having trouble with a DataTable in my dataset. this code don't
return
any rows:
data.database.datatable1.Select("username = '" + sName + "''");
The output should have been 4 rows, but I get 0 rows
I think this may be caused by a bad select (I'm a newbie to using
dataset, I prefer stored procedures.)
Is there a way I can see the select this code generate during runtime?
, I mean the entire select with the where clause generated in the
Select("username = '" + sName + "''");.... Then I could try that
select in Sql Server Management Express and hopefully solve the
problem...
any suggestions?
Jeff
What exactly is in your variable sName, and what exactly is in the field
username? Any spaces that throw the select off? Different casing (upper/lower)?
This Select() method does not generate a select query on the database,
instead it is a "sql-like" query on the dataset (datatable) itself. So there
is no "entire select" for you to inspect.
First build that query in a separate string variable, so you can inspect
that to see if there are any problems (unexpected spaces, embedded quotes).
Then use that variable in the Select() - no need to build the query twice.
Inspect the datatable: are the rows you want really there? The values
in the username column, are they what you expect?
If you select on other fields and/or values, do you get the expected rows
back?
(I think you can execute those queries in the QuickWatch window)
Hans Kesting