Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New Coder
    Join Date
    Apr 2011
    Posts
    19
    Thanks
    2
    Thanked 2 Times in 2 Posts

    What method to use

    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??

  • #2
    Regular Coder
    Join Date
    Apr 2009
    Posts
    244
    Thanks
    1
    Thanked 20 Times in 20 Posts
    Hey newbb,

    Here is how you can do that:
    http://msdn.microsoft.com/en-us/libr...t.toint32.aspx

    So, it would be:
    Code:
    _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

  • Users who have thanked Mike_O for this post:

    Fot (05-05-2011)

  • #3
    New Coder
    Join Date
    Apr 2011
    Posts
    19
    Thanks
    2
    Thanked 2 Times in 2 Posts
    Thanks for the help....


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •