I have a DataGridView
which is filled with the data that is in the table in my MySQL database.
But I don't want to get all the lines.
I have for example: Name Surname E_Mail text
I want to get the title Name Surname and so on
But what I don't want is that I also get for example: Max Musterman | email@at.at | blablabal
I only want to get the Title and it should work for all tables for example if I switch the table which has only 2 columns : Computer | Cost
I want to get in my DataGridView
Computer and Cost but again not the data for example HP 700€
I hope its clear what I want. But for now I get the Table title with the data and I don't want to get the data :(. Here is the code that gets me the whole table:
private void BindGrid()
{
IPHostEntry Host = Dns.GetHostEntry(Dns.GetHostName());
string IPAddress = Host.AddressList[1].ToString();
// MessageBox.Show(IPAddress);
string datasource = IPAddress;
string database = "datenbank";
string port = "xxx";
string UID = "xxx";
string pw = "xx";
string myConnection;
myConnection = string.Format("datasource=" + datasource + ";" + "Database=" + database + ";" + "port=" + port + ";" + "UID=" + UID + ";" + "password=" + pw);
using (MySqlConnection con = new MySqlConnection(myConnection))
{
using (MySqlCommand cmd = new MySqlCommand("SELECT * FROM Formular", con))
{
cmd.CommandType = CommandType.Text;
using (MySqlDataAdapter sda = new MySqlDataAdapter(cmd))
{
using (DataTable dt = new DataTable())
{
sda.Fill(dt);
dataGridView1.DataSource = dt;
}
}
}
}
}