Cannot be converted to 'Interger'

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
 
K

Kevin Spencer

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
 
C

chanmmn

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

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top