Cannot be converted to 'Interger'

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

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
 
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
 
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()
 
Back
Top