i am using VS 2010 to develop a site that gets some data from a database.
but i just keep getting this error.
'No value given for one or more required parameters.'
here is my code
Public Function getSessionDetails(ByVal roomId As String) As ArrayList
Dim sql As String
sql = "SELECT * FROM Table1 WHERE RoomId = ?"
Dim dbComm As New OleDbCommand(sql, dbConn)
'dbComm.Connection.Open()
dbComm.CommandText = sql
dbComm.Parameters.Add("RoomId", System.Data.OleDb.OleDbType.BSTR).Value = roomId
dbConn.Open()
'dbComm.ExecuteNonQuery()
Dim dbRead As OleDbDataReader = dbComm.ExecuteReader() 'System.Data.CommandBehavior.CloseConnection)
Dim arr As New ArrayList
Try
While dbRead.Read()
arr.Add(New SessionDetails(dbRead.GetValue(2).ToString, dbRead.GetValue(3).ToString, dbRead.GetValue(4).ToString, dbRead.GetValue(6).ToString, _
dbRead.GetValue(5).ToString, dbRead.GetValue(7).ToString, dbRead.GetValue(8).ToString))
End While
Catch ex As Exception
End Try
Try
'sort arr by date using bubble
For i As Integer = 1 To arr.Count - 1
Dim sesTop As SessionDetails = arr(i)
Dim sesBot As SessionDetails = arr(i - 1)
Dim sesTmp As SessionDetails
If sesBot.sessionDate < sesTop.sessionDate Then
'swap them
sesTmp = arr(i)
arr(i) = arr(i - 1)
arr(i - 1) = sesTmp
i = 0
ElseIf sesBot.sessionDate = sesTop.sessionDate And sesBot.StartTime < sesTop.StartTime Then
'swap them
sesTmp = arr(i)
arr(i) = arr(i - 1)
arr(i - 1) = sesTmp
i = 0
End If
Next
Catch ex As Exception
End Try
'Dim se As SessionDetails
'For Each se In arr
' If se.sessionDate < Now Then
' arr.Remove(se)
' End If
'Next
dbRead.Close()
dbConn.Close()
Return arr
End Function
Thanks for any help