Use to select a MySQL table by table name
using a drop down list.

This example shows how to use a drop down list to select a MySQL table in order to execute an sql command on the table selected:




This example assumes a MySQL Table called TABLELIST, with two columns in it called _NAME and _DESC. The _NAME column will contain a list of MySQL table names, and the _DESC column will contain a friendly description of the tables to select in the drop down.


75340 John's Table
40480 Jay's Table
30490 Jeff's Table

Note: This example assumes there are three MySQL tables named _75340, _40480, and _30490.

How it works:

The dropdown is showing the table "common names" of John's Table, Jay's Table, and Jeff's Table. If "Jay's Table" were selected, a posts back of 40480 will be made. Since all of our tables have an "_" in front of them, we will have to concatenate the "_" and the post back value. In this example the "table name" of 40480 is concatenated with the "_" so that it can select MySQL table "_40480" and execute an sql command on it. The command is a simple SELECT * command that is bound to  GridView1.

The table structure of the example tables isn't really important because all this code is doing is taking a list of tables and executing a "SELECT  * from TABLE" command.

This example is good to show how to concatenate a string in a SQL command that is MySQL friendly.


Tags: 3.5, Visual Basic, VB, MySQL 5.1, MySQL .net connector