CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2

Thread: Invalid Type

  1. #1
    Join Date
    May 2002
    Location
    Colombo,Sri Lanka
    Posts
    1,110

    Angry Invalid Type

    I'm very much new to VB.net arena
    following function gives me trouble



    Public Function GetBalHrs() As Double
    Try
    Dim objConn As New System.Data.SqlClient.SqlConnection(sConnection)
    Dim objReader As System.Data.SqlClient.SqlDataReader
    Dim strSql As String
    'strSql = "Select Sum(Hrs) as hrs From Project Where [Update] = 0 "
    strSql = "Select Programme From Project Where [Update] = 0 "
    Dim objcmd As New System.Data.SqlClient.SqlCommand()
    objConn.Open()
    objcmd.CommandText = strSql
    objcmd.Connection = objConn
    objReader = objcmd.ExecuteReader()
    objReader.Read()
    ' Dim a As String
    Return objReader.GetFloat(0)
    ' Return a
    Catch myException As System.Exception
    MessageBox.Show(myException.Message)

    End Try
    End Function

    Hrs field type is Float
    it says invalidTypecast
    How can I solve this

    Thankx in advance

  2. #2
    Join Date
    May 2002
    Location
    Colombo,Sri Lanka
    Posts
    1,110
    Thankx got it

    Then I change

    objReader.GetFloat(0) to objReader.GetValue(0)

    it is working now

Posting Permissions

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





Click Here to Expand Forum to Full Width

Featured