DataTable and DataGridView
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums
Results 1 to 2 of 2

Thread: DataTable and DataGridView

  1. #1
    Join Date
    Feb 2011

    DataTable and DataGridView

    Hi. I have followed this tutorial and i am now showing data in my DataGridView:

    void FillData()
                // 1
                // Open connection
                using (SqlCeConnection c = new SqlCeConnection(
                    // 2
                    // Create new DataAdapter
                    using (SqlCeDataAdapter a = new SqlCeDataAdapter(
                        "SELECT * FROM Animals", c))
                        // 3
                        // Use DataAdapter to fill DataTable
                        DataTable t = new DataTable();
                        // 4
                        // Render data onto the screen
                        dataGridView1.DataSource = t;
    Now I want to be able to modify the data and write it back to the database. How would i do this ? Create a function called SaveData and:
    - create a connection
    - create a new adapter ( that writes )
    - create the datatable
    - write datatable to new adapter using the connection

    I was wondering if that thought process is correct. I barely have any C# coding experiences alltho this does not seem so hard. Help is appreicated

  2. #2
    Join Date
    Feb 2011

    Re: DataTable and DataGridView

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Windows Mobile Development Center

Click Here to Expand Forum to Full Width

On-Demand Webinars (sponsored)