Hi all,
I've been banging my head on the desk with this one for over an hour now.
I've created an EmployeeDetails class with the following data members accessed through properties:
EmployeeID
FirstName
LastName
TitleOfCourtesy
There is a single New constructor defined as follows
This is a simple class and I'm happy all is well with it.
My problem is this:
I have developed another EmployeeDB class which handles connection to a database and retrieval of records. The problem I'm having is with the following:
I'm Getting the following error
Value of type 'System.Collections.ArrayList' cannot be converted to EmployeeDetails.
I'd be very grateful of someone could shed some light on this
Thankyou
I've been banging my head on the desk with this one for over an hour now.
I've created an EmployeeDetails class with the following data members accessed through properties:
EmployeeID
FirstName
LastName
TitleOfCourtesy
There is a single New constructor defined as follows
VB.NET:
Public Sub New(ByVal nEmployee As Integer, ByVal strFirstName As String, _
ByVal strLastName As String, ByVal strTitleOfCourtesy As String)
This is a simple class and I'm happy all is well with it.
My problem is this:
I have developed another EmployeeDB class which handles connection to a database and retrieval of records. The problem I'm having is with the following:
VB.NET:
Public Function GetEmployees() As EmployeeDetails
Dim objCon As New SqlConnection(connectionString)
Dim objCmd As New SqlCommand("GetAllEmployees", objCon)
objCmd.CommandType = Data.CommandType.StoredProcedure
Dim Employees As New System.Collections.ArrayList()
Try
objCon.Open()
Dim objReader As SqlDataReader = objCmd.ExecuteReader()
Do While objReader.Read()
Dim emp As New EmployeeDetails(CInt(objReader("EmployeeID")), _
CStr(objReader("FirstName")), _
CStr(objReader("LastName")), _
CStr(objReader("TitleOfCourtesy")))
employees.Add(emp)
Loop
objReader.Close()
Return Employees
Catch ex As Exception
End Try
End Function
I'm Getting the following error
Value of type 'System.Collections.ArrayList' cannot be converted to EmployeeDetails.
I'd be very grateful of someone could shed some light on this
Thankyou