0

I have here my code;

 dataGridView1.Rows.Clear();
            dataGridView1.Refresh();

            OleDbDataAdapter dAdapter = new OleDbDataAdapter("select * from Personaldata", connParam);


            OleDbCommandBuilder cBuilder = new OleDbCommandBuilder(dAdapter);

            DataTable dataTable = new DataTable();
            DataSet ds = new DataSet();

            dAdapter.Fill(dataTable);
            dataGridView1.DataSource = dataTable;


            for (int i = 0; i < dataTable.Rows.Count; i++)
            {
                dataGridView1.Rows.Add(dataTable.Rows[i][0], dataTable.Rows[i][1], dataTable.Rows[i][2], dataTable.Rows[i][3], dataTable.Rows[i][4], dataTable.Rows[i][5], dataTable.Rows[i][6], dataTable.Rows[i][7], dataTable.Rows[i][8], dataTable.Rows[i][9]);
            }

    }

"I have 9 columns in my table Personaldata"
" I got error InvalidOperationException was Unhandled
(Rows cannot be progmatically added to the DataGridView's rows collection when the control is data-bound)"
Pls help me, what should I do?

Edited by SkyCross

2
Contributors
1
Reply
12
Views
3 Years
Discussion Span
Last Post by oussama_1
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.