Webservice displays only 1 instead of ALL results
Hi there
I've just started with webservices and have written a small function to get all the records from a database matching a date string.
Anyway, it seems to find the relevant records but only displays ONE and not all.
I've tried using datasets, datareaders, etc. all still give me one record instead of every one matching my criteria.
Here is my code for the function.
<WebService(Namespace:="http://ZeusProject.com")> _
Public Class Service3
Inherits System.Web.Services.WebService
<WebMethod()> Public Function getconnectiondate(ByVal connectiondate As DateTime) As connectiondateresult
Dim Strconnect As String = dbstring2
Dim objconnect As New OleDbConnection(Strconnect)
Dim objcommand As New OleDbCommand()
Dim results As New connectiondateresult()
results.requestok = True
Dim selectaudit As String = _
"select * from accountdetails"
objcommand.Connection = objconnect
objcommand.CommandType = CommandType.Text
objcommand.CommandText = selectaudit
Dim objdataadapter As New OleDbDataAdapter()
objdataadapter.SelectCommand() = objcommand
Dim objdataset As New DataSet()
objcommand.CommandText = selectaudit
objconnect.Open()
objdataadapter.Fill(objdataset, "Audit")
Dim objDataView As New DataView()
' Dim objDataView2 As New DataView()
' Dim objDataView3 As New DataView()
If objdataset.Tables(0).Rows.Count > 0 Then
'If reader("connectiondate") = connectiondate Then
'If reader.GetSqlDateTime("connectiondate") = "" Then
'results.ismisc = True
'Else
' results.ismisc = False
'End If
results.exists = True
Dim tbl As DataTable = objdataset.Tables("Audit")
Dim row As DataRow = tbl.Rows(0)
' results.username = reader("username")
results.username = row("username")
'results.problemtype = reader("problemtype")
'results.usernumber = reader("usernumber")
Else
results.requestok = False
results.requestproblem = "Something's wrong"
End If
' Else
'results.requestok = False
'results.requestproblem = "No Misc calls here dude"
' End If
' Catch e As Exception
' reportedexception(e, results)
' ' Finally
' If Not connection Is Nothing Then connection.Close()
' 'If Not reader Is Nothing Then reader.Close()
' End Try
Return results
' End While
End Function
|