Cannot be converted to 'Interger'

Discussion in 'ASP .Net' started by =?Utf-8?B?VGltOjouLg==?=, Nov 3, 2004.

  1. Can someone tell me how I get around the following error?
    I keep getting the following error on the "RETURN ddlDataSet" line of my
    code! I don't know how to get arround this and would be grateful for any
    advice people may have to offer!

    Thanks..

    ...::Error
    value of type 'System.Data.DataSet' cannot be converted to 'Interger'

    ...:: CODE
    Function GetSelectedIndex(ByVal OID As String) As Integer
    'Populate the ddlDataSet
    Dim Myconn As New SqlConnection(ConfigurationSettings.AppSettings("strConn"))
    Dim myDataAdapter As SqlDataAdapter = New SqlDataAdapter("SelectOffice",
    Myconn)
    myDataAdapter.Fill(ddlDataSet, "Offices")
    Return ddlDataSet
    Dim iLoop As Integer
    Dim dt As DataTable = ddlDataSet.Tables("Offices")
    For iLoop = 0 To dt.Rows.Count - 1
    If Int32.Parse(OID) = Int32.Parse(dt.Rows(iLoop)("officeID")) Then
    Return iLoop
    End If
    Next iLoop
    End Function
    =?Utf-8?B?VGltOjouLg==?=, Nov 3, 2004
    #1
    1. Advertising

  2. You have defined a Function that is defined as returning an Integer. In case
    you didn't know, an Integer is a 32-bit whole number. If the function is
    defined as returning an Integer, it must return an Integer. A DataSet is not
    an Integer.

    --
    HTH,
    Kevin Spencer
    ..Net Developer
    Microsoft MVP
    I get paid good money to
    solve puzzles for a living

    "Tim::.." <myatix_at_hotmail.com> wrote in message
    news:...
    > Can someone tell me how I get around the following error?
    > I keep getting the following error on the "RETURN ddlDataSet" line of my
    > code! I don't know how to get arround this and would be grateful for any
    > advice people may have to offer!
    >
    > Thanks..
    >
    > ..::Error
    > value of type 'System.Data.DataSet' cannot be converted to 'Interger'
    >
    > ..:: CODE
    > Function GetSelectedIndex(ByVal OID As String) As Integer
    > 'Populate the ddlDataSet
    > Dim Myconn As New

    SqlConnection(ConfigurationSettings.AppSettings("strConn"))
    > Dim myDataAdapter As SqlDataAdapter = New SqlDataAdapter("SelectOffice",
    > Myconn)
    > myDataAdapter.Fill(ddlDataSet, "Offices")
    > Return ddlDataSet
    > Dim iLoop As Integer
    > Dim dt As DataTable = ddlDataSet.Tables("Offices")
    > For iLoop = 0 To dt.Rows.Count - 1
    > If Int32.Parse(OID) = Int32.Parse(dt.Rows(iLoop)("officeID")) Then
    > Return iLoop
    > End If
    > Next iLoop
    > End Function
    Kevin Spencer, Nov 3, 2004
    #2
    1. Advertising

  3. =?Utf-8?B?VGltOjouLg==?=

    chanmmn Guest

    Try Ctype function or for example:

    If myReader.HasRows Then
    Do While myReader.Read()
    Console.WriteLine(vbTab & "{0}" & vbTab & "{1}", myReader.GetInt32(0),
    myReader.GetString(1))
    Loop
    Else
    Console.WriteLine("No rows returned.")
    End If
    myReader.Close()


    "Tim::.." <myatix_at_hotmail.com> wrote in message
    news:...
    > Can someone tell me how I get around the following error?
    > I keep getting the following error on the "RETURN ddlDataSet" line of my
    > code! I don't know how to get arround this and would be grateful for any
    > advice people may have to offer!
    >
    > Thanks..
    >
    > ..::Error
    > value of type 'System.Data.DataSet' cannot be converted to 'Interger'
    >
    > ..:: CODE
    > Function GetSelectedIndex(ByVal OID As String) As Integer
    > 'Populate the ddlDataSet
    > Dim Myconn As New
    > SqlConnection(ConfigurationSettings.AppSettings("strConn"))
    > Dim myDataAdapter As SqlDataAdapter = New SqlDataAdapter("SelectOffice",
    > Myconn)
    > myDataAdapter.Fill(ddlDataSet, "Offices")
    > Return ddlDataSet
    > Dim iLoop As Integer
    > Dim dt As DataTable = ddlDataSet.Tables("Offices")
    > For iLoop = 0 To dt.Rows.Count - 1
    > If Int32.Parse(OID) = Int32.Parse(dt.Rows(iLoop)("officeID")) Then
    > Return iLoop
    > End If
    > Next iLoop
    > End Function
    chanmmn, Nov 3, 2004
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. uvbaz
    Replies:
    6
    Views:
    7,476
    uvbaz
    Sep 12, 2006
  2. I_have_nothing

    Any easy to printf an interger in 9,999, 99 format?

    I_have_nothing, May 13, 2005, in forum: C Programming
    Replies:
    4
    Views:
    391
    Chris McDonald
    May 13, 2005
  3. heng
    Replies:
    3
    Views:
    324
    Steven T. Hatton
    Dec 6, 2006
  4. Tim Slattery
    Replies:
    2
    Views:
    402
    Pete C
    Jan 6, 2007
  5. KG

    reverse the bits in an interger?

    KG, Jun 20, 2007, in forum: C Programming
    Replies:
    40
    Views:
    1,283
    Christopher Benson-Manica
    Jun 21, 2007
Loading...

Share This Page