Hello,
I have a problem with my RecordSet always being EOF but only with a certain SQL command. With other SQL commands it works and my RecordSet is filled with data.
What happens is that as soon as my program reaches “while not rs.EOF” it skips the entire loop, meaning that rs was already EOF. If I use “select * from systables where tabid > 99” then data is added to the comboboxes.
My table looks like this:
id | lastname | firstname | dateofbirth | email | phone
0 | Blogs | Joe | 05.06.1957 | joe@joe.net | 089 1111111
What I want to happen is that the column names for the table are put into the comboboxes.
Here’s my code:
[code] dim rs as recordset
’ we need that because without it, RS never works.
’ here’s why: “For this method to work, you need to have a property somewhere with SQLDatabaseMBS so Real Studio includes our SQLDatabase plugin which provides the RecordSet functionality.” - MBS
dim something as SQLDatabaseMBS = new SQLDatabaseMBS
dim cmd as SQLCommandMBS
cmd = new SQLCommandMBS
try
'cmd = new SQLCommandMBS(dbconnection, “select * from JWTestCustomers”)
cmd = new SQLCommandMBS(dbconnection, _
"SELECT colname " _
+ EndOfLine _
+ "FROM syscolumns,systables " _
+ EndOfLine _
+ "WHERE tabname = ‘JWTestCustomers’ " _
+ EndOfLine _
+ “and syscolumns.tabid=systables.tabid”)
cmd.Execute
if not cmd.isResultSet then
msgbox("Error with isResultSet")
return
end if
if DBConnection.error then
msgbox(DBConnection.ErrorMessage)
return
end if
rs = cmd.AsRecordSet
while not rs.EOF
ComboBoxFindBy.AddRow(rs.field("colname").StringValue)
ComboBoxFindBy2.AddRow(rs.field("colname").StringValue)
rs.MoveNext
wend
catch
msgbox("Error: "+DBConnection.ErrorMessage)
return
end try[/code]