I'm learning C#. The code as I show it works, but I want to pass the name of the table "city" as a parameter (@paramTable for example). None of the code I've found on the internet worked. Any suggestion is welcome, thanks!
public DataTable LoadGrid()
{
DataTable DTabla = new DataTable();
string str = "SELECT * FROM city WHERE ID < 10;";
MySqlCommand comando = new MySqlCommand(str, conexion);
if (this.AbrirConexion())
{
try
{
MySqlDataAdapter adapter = new MySqlDataAdapter(comando);
adapter.Fill(DTabla);
}
catch (MySqlException ex)
{
MessageBox.Show(ex.Message);
}
this.CerrarConexion();
}
return DTabla;
}