I have a DataGridView that I am using to put data in from an access database. I have it on the main form at the moment and when the form is open the grid is just greyed out.
When the button is clicked though, the information appears along with the columns. I would like the columns to be there before the button is clicked so when the form is opened you can see what the columns are minus the data.
I tried adding columns in design mode but when the button is clicked other columns simply get added on.
My current code is below.
string sConnection = "Provider=Microsoft.ACE.OLEDB.12.0;" + "Data Source=Sailing.accdb";
OleDbConnection conSailing = new OleDbConnection(sConnection);
conSailing.Open();
string sQueryShipsPort = "Select ShipName, Weight FROM Ships WHERE Inport = True ;";
OleDbDataAdapter dataadapter = new OleDbDataAdapter(sQueryShipsPort, conSailing);
DataSet ds = new DataSet();
dataadapter.Fill(ds, "Ships Table");
conSailing.Close();
dataGridView1.DataSource = ds;
dataGridView1.DataMember = "Ships Table";