这是我的代码来填充GridView
. 我希望能够对视图中的每一列进行更改。为了将所做的更改保存回 SQL 数据库,我缺少哪一步?
private void button1_Click(object sender, EventArgs e)
{
myConnection.Open();
Cursor.Current = Cursors.WaitCursor;
string query = @"select EmployeeId[Employee], DateIn, cast (timein as time(0)) [TimeIn], dateout, cast(timeout as time(0))[Time Out], job ,
costcode from Data_TimeCards_T WHERE (EmployeeID LIKE '%[^a-zA-Z0-9]%') or (job LIKE '%[^a-zA-Z0-9]%')";
OleDbDataAdapter dAdapter = new OleDbDataAdapter(query, myConnection);
OleDbCommandBuilder cBuilder = new OleDbCommandBuilder(dAdapter);
DataTable dTable = new DataTable();
dataGridView1.DataSource = dTable;
dAdapter.Fill(dTable);
DataGridView dgView = new DataGridView();
BindingSource bSource = new BindingSource();
bSource.DataSource = dTable;
dgView.DataSource = bSource;
dAdapter.Update(dTable);
myConnection.Close();
}