Yes, remember to use Convert.ToInt32 carefully, sometimes it doesn't work to
String convert , while Int32.Parse is ok.
I guess, if two types are convertable, such as Int to BigInt, or Object
to Int, System.Convert.Toxxx can work. String to Int is not
convertable, so Convert.Toxxx may be wrong sometime.
you can check MSDN for the types relation. That will give you details.
On 7 Jul 2004 14:17:21 -0700, oa*****@hotmail.com (chongo) wrote:
Hi,
i'm reading in a bigint value from SQL Server.
string s = myReader["BackColour"].ToString());
int intBackColour = System.Convert.ToInt32(s);
I'm also reading in other values the same way and it works great
except this one value, i'm getting
System.FormatException: Input string was not in a correct format.
I don't understand because when I print out the string s to the screen
it shows 0.
Does anyone have a idea why its doing this?
Any help would be greatly appreciated.
-dp
Very strange.
Try
int intBackColour = int.Parse(s);
instead of
int intBackColour = System.Convert.ToInt32(s);
-Adam