Thanks Karin .... guess I should have spotted that lol
Main Topics
Browse All TopicsHi ASP.noob here .... So I'm using this expensive book (ASP.NET 2.0 Moroney & MacDonald) to try and learn ASP.NET and in the code below I'm following the book examples to try and build the database abstraction layer... only trouble is I can't get it to work & neither can the ASP.NET compiler...
The error occurs on the line
Return alC
ports Microsoft.VisualBasic
Public Class ContactDetails
Dim lngID As Integer
Dim strFN, strLN As String
Public Property ID() As Integer
Get
Return lngID
End Get
Set(ByVal value As Integer)
lngID = value
End Set
End Property
Public Property FirstName() As String
Get
Return strFN
End Get
Set(ByVal value As String)
strFN = value
End Set
End Property
Public Property LastName() As String
Get
Return strLN
End Get
Set(ByVal value As String)
strLN = value
End Set
End Property
Public Sub New(ByVal intID As Integer, ByVal strFN As String, ByVal strLN As String)
Me.ID = intID
Me.FirstName = strFN
Me.LastName = strLN
End Sub
End Class
Public Class SESDB
Dim strCS As String 'Connection string
Dim strSC As String 'Search Criteria
Public Property SearchCriteria() As String
Get
SearchCriteria = strSC
End Get
Set(ByVal value As String)
strSC = value
End Set
End Property
Public Function SearchContacts() As ContactDetails()
Dim cnn As New Data.OleDb.OleDbConnection
Dim cmd As New Data.OleDb.OleDbCommand
Dim strSQL As String
Dim alC As New ArrayList
Try
strSQL = "SELECT cID,FirstName,LastName FROM tblContacts WHERE LastName='" & strCS & "'"
cnn.Open()
cmd.CommandType = Data.CommandType.Text
cmd.CommandText = strSQL
Dim rdr As Data.OleDb.OleDbDataReader
Do While rdr.Read
Dim cntct As New ContactDetails( _
CInt(rdr("cID")), _
CStr(rdr("FirstName")), _
CStr(rdr("LastName")))
alC.Add(cntct)
Loop
rdr.Close()
Return alC <----- Error here!
Catch ex As Exception
Throw New ApplicationException("Data
Finally
cnn.Close()
End Try
End Function
Public Sub New()
strCS = System.Web.Configuration.W
End Sub
End Class
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
Business Accounts
Answer for Membership
by: KarinLoosPosted on 2007-05-31 at 03:26:36ID: 19186785
Problem is reasonably simple
"Public Function SearchContacts() As ContactDetails() "
your function is declared to return an object of type ContactDetails
and you are returning an arraylist.
Change to
Public Function SearchContacts() As ArraylLst()