So I’m trying to get my WebService App to send a reply to a client App as JSON.
I am able to boot both applications (The WebService and Client Test App) fine however once I press the button in the test app I get a “NilObjectException” Error in the Web Service App on the line in Bold Italics below:
Dim sql As String
sql = "SELECT * FROM Contacts"
Dim rs As RecordSet
[b][i]rs = DB.SQLSelect(sql)[/i][/b]
If DB.Error Then
System.DebugLog("DB Error: " + DB.ErrorMessage)
Dim jsonError As New JSONItem
jsonError.Value("DBError") = DB.ErrorMessage
End If
Dim jsonContacts As New JSONItem
Dim cont As New Dictionary
While Not rs.EOF
cont = New Dictionary
cont.Value("fullname") = rs.Field("fullname").StringValue
jsonContacts.Value(rs.Field("fullname").StringValue) = cont
rs.MoveNext
Wend
rs.Close
Dim jsonResults As New JSONItem
jsonResults.Value("GetAllContacts") = jsonContacts
Thanks for your replies, the Line before the Nil is below in bold:
Dim data As Text = DefineEncoding(Request.Entity, Encodings.UTF8).ToText
Dim json As JSONItem
Select Case Request.Path // /GetAllContacts
Case "GetAllContacts"
json = [b]GetAllContacts[/b]
Request.Status = 200
Case "GetContact"
json = GetContact
Request.Status = 200
Case Else
// Do not process request
Return False
End Select
Request.Print(json.ToString)
Return True
Also I have this Event Handler which would bring up an error message if the DB wasn’t connected (the DB is in the folder as the project):
Dim dbFile As FolderItem
dbFile = GetFolderItem("edata.db")
If Not dbFile.Exists Then
System.DebugLog("DB not found: " + dbFile.NativePath)
Quit
End If
DB = New SQLiteDatabase
DB.DatabaseFile = dbFile
If Not DB.Connect Then
System.DebugLog("Could not connect to database: " + DB.ErrorMessage)
Quit
End If
System.DebugLog("Connect to database: " + dbFile.NativePath)
thats is what I tried to tell him, but seems it just passed by… can’t work with incomplete and/or conflicting information… too early in the morning for that
Was not being rude… you provided incomplete and conflicting information, and it is an investement of time for us to help you.
You have twice been given the probable cause,