I have a database with 28 columns. First column is code, second Name and the rest are values.
public void displayData()
{
con.Open();
MySqlDataAdapter da = new MySqlDataAdapter("SELECT * FROM gehaltes", con);
DataTable dt = new DataTable();
da.Fill(dt);
dataGridView1.DataSource = dt;
dataGridView1.AutoResizeColumn(DataGridViewAutoSizeColumnsMode.DisplayedCells);
con.Close();
}
With this part of the program I see all the columns in the datagridview. I only want the first 2 but I have to use all the 28 columns if I want to make changes.
SELECT *?? Generally a good idea to always specify the columns in the order you want. You dont need all the columns to make changes unless you will be changing something in those other 26 column; which seems less likely if the user cant see/edit them