无法在GridView中进行更改以保存到数据库

时间:2013-09-12 02:03:19

标签: c# sql winforms gridview

以下是填充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();
}

0 个答案:

没有答案