Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Get a column value from a datatable

Reply
Thread Tools

Get a column value from a datatable

 
 
Microsoft News Group
Guest
Posts: n/a
 
      09-22-2006
I am trying to get a value from the MIN column in my database. I can not
seem to get the IF statement to be true, even thou my debugging says the
column value is 0, but it is not hitting the return true. Is there anyway
to get the column value to test it to equal zero.



public static bool GetPriceRangesByMin()

{



using(DataTable table = GetPriceRanges())

{

foreach (DataRow row in table.Rows)

{


if(row["Min"].Equals(0))


{


return true;

}

}

return false;

}

}



 
Reply With Quote
 
 
 
 
Mark Rae
Guest
Posts: n/a
 
      09-22-2006
"Microsoft News Group" <(E-Mail Removed)> wrote in message
news:%(E-Mail Removed)...

> if(row["Min"].Equals(0))


Ah yes, but what datatype is "Min"? Try this:

return Convert.ToInt32(row["Min"]) == 0;


 
Reply With Quote
 
 
 
 
Microsoft News Group
Guest
Posts: n/a
 
      09-24-2006
Thanks, I used this.

// Convert "Min" field to a decimal.

value = row["Min"].ToString();

intValue = Decimal.Parse(value);



But now I am trying to change a null value of a datatable, because a row
contains a null value and it doesnt like it. I am trying to do this.

table[0].Rows[0].ItemArray[6] = String.Empty;

But it is not replacing the item in the datatable. Any other ways to do
this. I know theres a SetColumnNameNull(), but that didnt work.

"Mark Rae" <(E-Mail Removed)> wrote in message
news:%(E-Mail Removed)...
> "Microsoft News Group" <(E-Mail Removed)> wrote in message
> news:%(E-Mail Removed)...
>
>> if(row["Min"].Equals(0))

>
> Ah yes, but what datatype is "Min"? Try this:
>
> return Convert.ToInt32(row["Min"]) == 0;
>
>



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
sending a value from a datatable column.. gbattine Java 0 09-06-2006 11:20 AM
What is the Syntax for changing a DataTable column value? keithb ASP .Net 1 05-04-2006 02:34 AM
Test if a value exists in a DataTable Column? MattB ASP .Net 2 11-11-2005 06:38 PM
Create a Datatable from a SQL datatable column shema? jg ASP .Net 1 08-17-2004 09:43 PM
Adding DataTable Rows To another DataTable J. Babe ASP .Net 1 08-15-2003 05:04 PM



Advertisments