...

View Full Version : What method to use



newbb
05-04-2011, 09:28 AM
Hi readers and programmers!

I need some advice what method should I use to convert a variable to an interger. Here's my code:

_badge_no = ds.Tables[0].Rows[0]["badge_no"].Int32();

whenever i run the page the browser tells me that:

Compiler Error Message: CS0117: 'object' does not contain a definition for 'Int32'

Any idea??:confused:

Mike_O
05-04-2011, 03:24 PM
Hey newbb,

Here is how you can do that:
http://msdn.microsoft.com/en-us/library/system.convert.toint32.aspx

So, it would be:

_badge_no = Convert.ToInt32(ds.Tables[0].Rows[0]["badge_no"]);
Of course, it is always better to pre-define your DataTable schema so that you don't have to make this conversion every time.

Regards,
Mike

newbb
05-05-2011, 09:05 AM
Thanks for the help....
:)



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum