Click here to Skip to main content
15,911,531 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,
i have a dataset which contains a table "ClassName" with 2 columns "ID" and "class" and many rows in the table and when i used
DataRow[] aRow=dataset.Tables[0].Select("ID=(somevalue) and class=(somevalue)")
it's not returning rows into the datarow for given column values and if i change the value of the column it"s returning(ie it"s returning rows for some values only)
and when I checked in the visualiser during debugging the rows are present there but it"s
not returning into the the datarow.


Please help me regarding the same.
Posted
Updated 25-Mar-11 0:17am
v3

Before we can work out what is going on, you need to check a few things.

1) Are you reading the correct info into the DataSet in the first place? If so, show the code fragment.
2) How can you tell it is not returning the "right" data? What values is it returning?

Edit your question, and give us the relevant code fragments for the DataSet load, the actual Select method call, and the read-out of your DataRow array.
 
Share this answer
 
Try setting your expression to this:

C#
dataset.Tables[0].Select("ID='somevalue' and class='somevalue'");
 
Share this answer
 
Comments
siva455 25-Mar-11 6:22am    
really thanks for your help..it"s working now..but my doubt is how come it is returning for other values eventhough i give expression like
dataset.Tables[0].Select("ID=somevalue and class=somevalue");
#realJSOP 25-Mar-11 7:37am    
I don't understand your question. Are you saying that if you specify "ID='5'", it's giving you records where ID isn't necessarily equal to '5'?
can you try the same by changing the select string as

DataRow = dataset.Tables[0].Select("ID = '" &(SomeValue like text from a text box)&"' AND class='"& (SomeValue like text from a text box)&"'" ).

If you still face the problem, can you post your exact code
 
Share this answer
 
Comments
rayaprasuna 26-May-12 5:50am    
<asp:DropDownList ID="ddlSubCategory" runat="server" AppendDataBoundItems="True"
CssClass="DropDownStyle" DataTextField="SubCategoryName" DataValueField="SubCategoryId"
OnSelectedIndexChanged="ddlSubCategory_SelectedIndexChanged" TabIndex="13">
<asp:ListItem Value="0">Any


iam using the static dataset as

static dataset dsall =new dataset();

dsall.Tables[1].Select("GeneralCategoryId = '" + Int32.Parse(ddlGeneralCategory.SelectedValue) + "'");
ddlSubCategory.DataBind();

for this iam getting the error: DataBinding: 'System.Data.DataRow' does not contain a property with the name 'SubCategoryName'.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900