Database Metadata and Mouse Event

I need to know code example that allows:

  1. How to get the name of each table from a database of any platform (MySQL, Oracle, SQL Server, Postgres)?
  2. How to get the name of each view of a database from any platform (MySQL, Oracle, SQL Server, Postgres)?
  3. Knowing a database table or view how to get your fields and how to know what your primary key and foreign keys are?
    04.Is it possible to get the relationships of all the tables in a database with keys and primary key?
  4. How to perform a drag and drop of a text component?
    06.How to create a component dynamically?
    07.How to increase the length of a text component with movement
    of mouse?
    Thanks…
rs = MyDatabase.TableSchema

This returns a recordset with all the table names of your database.
See THIS docs page for more info

rs = MyDatabase.FieldSchema( "MyTableName" )

This returns a recordset with info about the fields inside a table.
The boolean value " rs.field(“IsPrimary”) " determines whether a field is the primary key.
See THIS docs page for info on the FieldSchema

As for relationships… I use SQLite most of the times. I make my relationships with adding triggers. Those triggers defer for each db system you intent to use.

As for the mouse events…

You might want to play around with the MouseDrag events. There are example projects that came with Xojo that explain how to drag controls in a window.

Creating controls dynamically is explained in THIS webinar. And can be found in the example projects as well.

What do you mean with increasing the length of a Text component? Do you wish to resize one? That could be done with the MouseMove event. You might want to set a property of the X property of the mouse in the MouseDown event. When dragging you can calculate the distance between the “Old X” value and the current X. Use that distance to set the Width of the Text field.

Note: If you have questions regarding different subjects, it might be better to create a forum conversation for each one. This way a conversation might be more useful for other people that may be looking for the same things. And it keeps the forum a bit cleaner.

Edwin, thanks.
And about the metadata of a database?

Sorry, I saw the previous message now …
Thanks

You’re welcome…

Meta data is system specific. You might want to perform a SQLselect on a system table. Same for getting the views.

You will have to check the documentation of that specific database engine.
Some metadata of a SQLite column can be found HERE.
Some SQLite info for the database resides in the sqlite_master table

select * from sqlite_master;

Of course you can add a WHERE clause to filter the results.

For other systems you might want to turn to google :slight_smile:

thanks, Edwin.
Does xojo accept third-party libraries like DLL and jar files?

Yes, you can call the functions inside a DLL using Declare statements. I work with a Mac. And I am not really experienced with Declares.
In the Doc Pages you can find more info.
Also, you might want to check the Forum to find people with similar questions :slight_smile:

(maybe this one?)

You can use jar files including JDBC driver with our MBS Java Plugin:
http://www.monkeybreadsoftware.de/xojo/plugin-java.shtml

We also provide a SQL Plugin for access to 12 database types via native drivers:
http://www.monkeybreadsoftware.de/xojo/plugin-sql.shtml