By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
431,983 Members | 1,717 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 431,983 IT Pros & Developers. It's quick & easy.

InvalidOperationException was unhandled

lotus18
100+
P: 866
Expand|Select|Wrap|Line Numbers
  1. Private Data As OleDbDataReader
  2. Private Command As New OleDbCommand
  3.  
  4. Friend Function Conflict(ByVal DayID As String, ByVal Room As String, ByVal _
  5.  NewTimeStarted As Date, ByVal NewTimeFinished As Date, ByVal SectionUnit As String, _
  6.   ByVal Semester As String) As Boolean
  7.         'Dim SectionUnit As String
  8.         'SectionUnit = Course & " " & Section
  9.         'Conflict = False 'Default Value
  10.  
  11.  
  12.         Main.SetConnection() 'Set Database Connection
  13.  
  14.         'PHASE 1 | CHECK ROOM SCHEDULES
  15.         Command = New OleDbCommand("Select * From LoadSchedules Where Rooms.Title='" & Room & _
  16.        "' And Not Rooms.Title='Field' And Semester='" & Semester & "' And DayID='" _
  17.        & DayID & "'", dbConnection)
  18.         Command.CommandType = CommandType.Text
  19.         Data = Command.ExecuteReader
  20.  
  21.         If (Data("TimeStarted") >= NewTimeStarted) And (Data("TimeStarted") < NewTimeFinished) Then
  22.             Conflict = True
  23.             'MsgBox "1 | Conflict sa 1st day. May nakaschedule na sa room na ito."
  24.             ShowConflict(Data("SectionUnit"), _
  25.             Data("Rooms.Title"), Data("DayID"), _
  26.             Data!TimeStarted, Data!TimeFinished)
  27.             Exit Function
  28.         End If
  29.  
  30.         Data.Close()
  31. End Function
The bold text says "No data exists for the row/column" Please help :'(

Rey Sean
Jun 19 '08 #1
Share this Question
Share on Google+
2 Replies


jeffstl
Expert 100+
P: 432
You need to make sure you reader is actually pulling data.

Sounds like its not which means either your query is not right, or the database doesn't have the data you are expecting it to have.

Expand|Select|Wrap|Line Numbers
  1.  
  2. If Data.Read then
  3.      'your data is there
  4. else
  5.      'your data is not there
  6. end if
  7.  
  8.  
Jun 19 '08 #2

lotus18
100+
P: 866
You need to make sure you reader is actually pulling data.

Sounds like its not which means either your query is not right, or the database doesn't have the data you are expecting it to have.

Expand|Select|Wrap|Line Numbers
  1.  
  2. If Data.Read then
  3.      'your data is there
  4. else
  5.      'your data is not there
  6. end if
  7.  
  8.  
You are a little bit right. I've change the query

Expand|Select|Wrap|Line Numbers
  1. [color=#222222]
  2. [font='Courier New',Courier,monospace]Private Data As OleDbDataReader[/font]
  3. [font='Courier New',Courier,monospace]Private Command As New OleDbCommand[/font]
  4. [font='Courier New',Courier,monospace] [/font]
  5. [font='Courier New',Courier,monospace]Friend Function Conflict(ByVal DayID As String, ByVal Room As String, ByVal _[/font]
  6. [font='Courier New',Courier,monospace] NewTimeStarted As Date, ByVal NewTimeFinished As Date, ByVal SectionUnit As String, _[/font]
  7. [font='Courier New',Courier,monospace]  ByVal Semester As String) As Boolean[/font]
  8. [font='Courier New',Courier,monospace]        'Dim SectionUnit As String[/font]
  9. [font='Courier New',Courier,monospace]        'SectionUnit = Course & " " & Section[/font]
  10. [font='Courier New',Courier,monospace]        'Conflict = False 'Default Value[/font]
  11. [font='Courier New',Courier,monospace] [/font]
  12. [font='Courier New',Courier,monospace] [/font]
  13. [font='Courier New',Courier,monospace]        Main.SetConnection() 'Set Database Connection[/font]
  14. [font='Courier New',Courier,monospace]        'PHASE 1 | CHECK ROOM SCHEDULES[/font]
  15. [font='Courier New',Courier,monospace]        Command = New OleDbCommand("Select * From LoadSchedules Where Rooms.Title='" & Room & _[/font]
  16. [font='Courier New',Courier,monospace]       "' And Not Rooms.Title='Field' And Semester='" & Semester & "' And DayID='" _[/font]
  17. [font='Courier New',Courier,monospace]       & DayID & "'", dbConnection)[/font]
  18. [font='Courier New',Courier,monospace]        Command.CommandType = CommandType.Text[/font]
  19. [font='Courier New',Courier,monospace]        Data = Command.ExecuteReader[/font]
  20. [font='Courier New',Courier,monospace] [/font]
  21. [font='Courier New',Courier,monospace]        If Data.Read Then[/font]
  22. [font='Courier New',Courier,monospace]            Conflict = True[/font]
  23. [font='Courier New',Courier,monospace]            'MsgBox "1 | Conflict sa 1st day. May nakaschedule na sa room na ito."[/font]
  24. [font='Courier New',Courier,monospace]            ShowConflict(Data("SectionUnit"), _[/font]
  25. [font='Courier New',Courier,monospace]            Data("Rooms.Title"), Data("DayID"), _[/font]
  26. [font='Courier New',Courier,monospace]            Data!TimeStarted, Data!TimeFinished)[/font]
  27. [font='Courier New',Courier,monospace]            Exit Function[/font]
  28.                    Else
  29.                              Conflict = False
  30. [font='Courier New',Courier,monospace]        End If[/font]
  31. [font='Courier New',Courier,monospace] [/font]
  32. [font='Courier New',Courier,monospace]        Data.Close()[/font]
  33. [font='Courier New',Courier,monospace]End Function[/font]
[/color]
  •  
  • Thanks : )

    Rey Sean
    Jun 21 '08 #3

    Post your reply

    Sign in to post your reply or Sign up for a free account.

    Browse more Visual Basic 4 / 5 / 6 Questions on Bytes