I copied code from another section of the project that is working. I have a database opened and am getting a RowSet back. But I need to look over this RowSet and get various columns of data.
So instead of using:
S=rs.Column(“CompanyName”).StringValue
I need to use something like this:
S=“CompanyName”
S=rs.Column(S).StringValue
But this throws an InvalidArgumentException, “no column named CompanyName”
Yet I see the vairables in the debugger, a rowset with the “CompanyName” column.
What am I missing.
Dim I As Integer
Dim S As String
Dim T As Text
Dim Relates As Boolean
Dim TableName As String
Dim ColumnToMatch As String
Dim MatchName As String
Dim ColumnToReturn As String
Dim ErrorMess As String
Dim rs As RowSet
Dim Lb As WebListBox
Lb=ListBoxCompanies
// NO Error checking//
rs=Session.GetAllFromDBRowSet("Company")
If rs Is Nil Then Return
LB.DeleteAllRows
If rs <> Nil Then
ErrorMess=""
For Each row As DataBaseRow In rs
LB.AddRow("")
Try
S="CompanyName"
// S=rs.Column(S).StringValue
S=rs.Column(S).Value ////// <--------------------- this causes an InvalidArgumentException.
LB.Cell(LB.LastIndex, I) = S
Next
Catch e As NilObjectException
MessageBox("Nil Object")
End Try
Next
rs.Close
End
That’s true only if you quote the column names. By default Postgres is NOT case sensitive, so “Select * from Company” is the same as “Select * from company”.
Using more quote marks also failed.
I suspect I need to write a routine to list the columns that Xojo is seeing in this routine to learn why there is a mis-match.
The SqlIte database is from the client, so … who knows what corruption there may be. However, DB Browser for SQLite lets me see the data. Not sure why this is happening. May be time to restart the computer …
I found the by deleting the “CompanyName” and retyping the line worked.
There must have been some non-printing char in the copy/paste buffer from when I copied the field name from the database.
While the result you describe is right, technically PostgreSQL is case-sensitive. It’s just that it internally converts all identifiers to lowercase unless quoted.
When copying text out of PgAdmin (if that is what you did) often adds an invisible LineFeed character to the start of the text. If you arrow across the text you can see the cursor not move once on the first character.