Click to See Complete Forum and Search --> : Invalid Type


dinesh123
December 10th, 2002, 04:52 AM
I'm very much new to VB.net arena
following function gives me trouble

:mad:

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

dinesh123
December 11th, 2002, 12:33 AM
Thankx got it

Then I change

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

it is working now
:cool: