I'm converting the free Survey Module from the SQL one into an Access Database version. It's been quite educational, which is mostly what I'm doing it for right now.
Anyway, I've worked through many error messages, and have come to one I just can't crack myself. I've tried doing some searching on the web but I can't find a solution to my headache. The problem is when I add the Survey Module to a page it doesn't have any default question or anything in the database. Problem is, when the page loads it tries to find out if there are any questions, and when it runs this particular module it errors out complaining the following error message:
Exception Details: System.InvalidOperationException: No data exists for the row/column.
Here is what is calling the function, from the .ascx page:
----
Dim RowCount As Integer = 0
RowCount = SurveyCheck.ExistSurvey(ModuleId)
If RowCount > 0 Then...
-----
Here is the entire function. I do now that if I manually add a Survey Question into the database then this does not occur. So I'm guessing that since there is nothing setup in the database that it is freaking over a null value or some type of thing. I've gone over the SQL method and the Access method a few times and can't seem to find out if I can set a trap to set a default if no records are returned. Help!
---
Public Function ExistSurvey(ByVal ModuleID As Integer) As Integer
Dim myTools As New Tools()
Dim myRTConnection As String = myTools.GetConnectionString()
'<-- Create Instance of Connection and Command Object -->
Dim myConnection As New OleDbConnection(myRTConnection)
Dim mySQL As String = "SELECT SurveyID FROM Surveys WHERE (ModuleID = " & ModuleID & ")"
myConnection.Open()
Dim myCommand As New OleDbCommand(mySQL, myConnection)
Dim myReader As OleDbDataReader = myCommand.ExecuteReader(CommandBehavior.CloseConnection)
myReader.Read()
Dim MyRowCount As Integer = 0
MyRowCount = myReader.GetInt32(0)
myReader.Close()
myConnection.Close()
Return CInt(MyRowCount)
End Function
---
Otherwise, I think most of the rest of the module works fine, but I have only been able to test parts of it so far.
Brian
______________
B. Young
www.az-ta.com