473,326 Members | 2,010 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,326 software developers and data experts.

Cannot be converted to 'Interger'

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
Nov 18 '05 #1
2 1203
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:97**********************************@microsof t.com...
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

Nov 18 '05 #2
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:97**********************************@microsof t.com...
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

Nov 18 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
by: baustin75 | last post by:
Posted: Mon Oct 03, 2005 1:41 pm Post subject: cannot mail() in ie only when debugging in php designer 2005 -------------------------------------------------------------------------------- ...
1
by: gi75research | last post by:
What should be a very simple function is going terribly wrong, and I don't know why. StartTime and EndTime are table values (formatted like "01:00A" or "02:00P"); DaypartStart and DaypartEnd are...
2
by: Sean | last post by:
Hello, I have a function in C# that accepts a stored proc name and an array of parameters, and then returns a dataset, which works just fine. I have converted the function to VB: Public Shared...
2
by: Johan Delimon | last post by:
"The active directory datatype cannot be converted to/from a native DS datatype" I have an ASP.NET web page that uses queries to AD to identify current users. Delegation is configured in AD and...
4
by: Barry | last post by:
object type cannot be converted to target type - i am getting this error message occuring numerous times in my task list, my project compiles and runs ok but it is a nuisance, I think Ihva eheard of...
2
by: Jim in Arizona | last post by:
I'm learning form an ASP.NET 1.0 book and I tried out some code that returns this error: Compiler Error Message: BC30311: Value of type 'Integer' cannot be converted to...
2
by: William Manley | last post by:
Is there a way to check if a string can be a interger without crashing the program?
40
by: KG | last post by:
Could any one tell me how to reverse the bits in an interger?
1
by: www.phpbasic.com | last post by:
i have a problem with interger number in PHP <?php class read{ var $num; function read($num){ $this->num = $num; } function basic(){ print "NUM: ".($this->num); }
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.