I need to get my object
Hello,
I am tring to return a employee object to my GUI Page from a dataaccess page. Every thing seems to do fine until the function try's to return the employee object from the Ordional Postion of (0) from the EmployeeList Innerlist. I am getting stuck on the GET and the Return CType(Me.Item(index), Employee) . Wehn i step into the code It just goes back and forth like it is stuck or something. Like a broken record.. And when i just run the application i get an error message that there is a overflow error.
Can someone please look at this and let me know where i need to make chages?
I can post all of the code if i need to..
Thanks,
Erik,..
If you will look below; this is where i am tring to return the employee object
Default Public ReadOnly Property Item(ByVal index As Int32) As Employee
Get < ******Stuck here********
Return CType(Me.Item(index), Employee) < ***** AND HERE
Gui....................................
Dim EmpAss As New EmployeeAccess
ddl.DataSource = EmpAss.PopEmployee(2)
ddl.DataBind()
------------------------------------------------------------
DataAccess-----------------
Public Function PopEmployee(ByVal Empid As Int32) As Employee
PopEmployee = GenericDataAccess("Employee_Byid", "@Employeeid", Empid)
End Function
'
'
Dim Emp_Data_List As New EmployeeCollections
Private Function GenericDataAccess(ByVal CommandText As String, _
ByVal ParamName As String, _
ByVal ParamValue As String) As Employee
With Data_Connection
.Open()
End With
'
With Data_Command
.CommandText = CommandText
.CommandType = CommandType.StoredProcedure
With Data_Command.Parameters
.Add(ParamName, SqlDbType.Int, 4).Value = ParamValue
End With
.Connection = Data_Connection
End With
'
Data_Reader = Data_Command.ExecuteReader
While Data_Reader.Read
Emp_Data_List.Add(New Employee(Data_Reader("FirstName"), _
Data_Reader("LastName"), _
Data_Reader("City"), _
Data_Reader("Employeeid")))
End While
With Data_Connection
.Close()
End With
'
With Data_Reader
.Close()
End With
'
With Data_Command
.Dispose()
End With
'
Return Emp_Data_List(0)
'
'
End Function
================================================== =
CollectionBase---------------------------------
Public Class EmployeeCollections : Inherits CollectionBase
Public Function Add(ByVal Employee As Employee) As Int32
Return Me.InnerList.Add(Employee)
End Function
'
Default Public ReadOnly Property Item(ByVal index As Int32) As Employee
Get
Return CType(Me.Item(index), Employee)
End Get
End Property
End Class
|