Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Cannot be converted to 'Interger'

Reply
Thread Tools

Cannot be converted to 'Interger'

 
 
=?Utf-8?B?VGltOjouLg==?=
Guest
Posts: n/a
 
      11-03-2004
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("s trConn"))
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
 
Reply With Quote
 
 
 
 
Kevin Spencer
Guest
Posts: n/a
 
      11-03-2004
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:(E-Mail Removed)...
> 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("s trConn"))
> 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



 
Reply With Quote
 
 
 
 
chanmmn
Guest
Posts: n/a
 
      11-03-2004
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:(E-Mail Removed)...
> 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("s trConn"))
> 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



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Datatable cannot be converted to Datatable jbeckh2@gmail.com ASP .Net 0 01-12-2007 04:04 PM
The active directory datatype cannot be converted to/from a native =?Utf-8?B?Sm9oYW4gRGVsaW1vbg==?= ASP .Net 2 05-02-2005 03:31 PM
Error "Cannot be converted into parameter type System.Data.DataTable" Chun ASP .Net 0 07-19-2004 03:26 PM
value of type "MyNamespace.MyClassName" cannot be converted to "MyNamespace.MyClassName" Mike Schnorr ASP .Net 0 06-25-2004 12:17 PM
Value of type 'String' cannot be converted to '1-dimensional array of System.Object' =?Utf-8?B?U2Vhbg==?= ASP .Net 2 02-06-2004 01:25 PM



Advertisments