SQL Window similar to Example Ïnteractive Shell

I am struggling to make a SQL prompt box which will execute immediate and see the results as I would in SQLite3. To visualize what I am trying to do is to use the sample OS Command Shell example in the Advanced / Shell Interactive Shell examples, but execute it in sqlite. I may enter any valid sqlite command, (system ie .dump, DDL or DML)

As always any assistance is greatly appreciated.

there are two types of interaction, I suppose:

  1. execute
  2. query

In case of execute:

try
  app.database.ExecuteSQL(sql)
Catch error As DatabaseException
  MessageBox error.message
End Try

it is simple, you’ll get error message text to show/display or just display OK when there was no error.

In case of query (select…) you probably would like to see a table with columns filled with database rows. You can do normal selectSQL:

var r as rowset=app.database.SelectSQL(sql)
ListboxQuery.ColumnCount=r.ColumnCount //set the listbox to as many columns as they are returned from SelectSQL..

//then insert names of RowSet columns into Listbox headers:

for x as integer = 1 to r.ColumnCount
  ListboxQuery.HeaderAt(x-1)=r.ColumnAt(x).Name
next

…and the follow filling the listbox from RowSet as usual

1 Like

small update due to my error:

for x as integer =0 to r.ColumnCount-1
  ListboxQuery.HeaderAt(x)=r.ColumnAt(x).Name
next