By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,143 Members | 865 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,143 IT Pros & Developers. It's quick & easy.

Select Method for System.Data.DataTable

P: n/a
Hi,

Im trying to use the Select method for the DataTable
objects of the System.Data library. The problem is that
when the datatype of the object that's being searched is
an string, I get the correct DataRows from the DataTable,
but if the datatype is an integer or a decimal, then I
get nothing...

Heres part of the code

dtDocs = new DataTable("Rec");

dtDocs.Columns.Add("CxC", System.Type.GetType
("System.Int32"));
dtDocs.Columns.Add("PaymentForm");

//somewhere in the code I populate the DataTable

DataRow dr = dt.NewRow();
dr["CxC"] = 4;
dr["PaymentForm"] = "Cash";
dt.Rows.Add(dr);

//then I use the select
//assuming that DataTable has a row which contains a 4 in
//column cxc

string str = "4";
DataRow[] foundrows = dt.Select("CxC = " + str);

//Here foundrows.Length return 0

string str = "Cash";
DataRow[] foundrows2 = dt.Select("PaymentForms = "+ str );

//Here foundrows2.Length= 1

What can I do??? I need urgent help...

Thanks
Nov 15 '05 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.