0

In my C# project, i populated the values in DataGrid from DataTable. Now if i make changes in the values in the DataGrid i need to update them in the DataBase. I'm using MS access. Here is the code snippet of how i populate values in the DataGrid.

                    while (myReader.Read())
                {
                    frmBind.dr = frmBind.dtResults.NewRow();
                    frmBind.dr["ClassName"] = myReader.GetString(0);

                    frmBind.dr["MethodSignature"] = myReader.GetString(1);

                    frmBind.dr["ParameterValues"] = myReader.GetString(2);
                    frmBind.dr["ExpectedResults"] = myReader.GetString(3);


                    frmBind.dtResults.Rows.Add(frmBind.dr);

                }

                frmBind.dataGrid2.DataSource = frmBind.dtResults;

where, dtResults is DataTable, frmBind is a Class Object, dataGrid2 is the DataGrid, myReader.Read() is used to get the values from the DataBase.

1 Answer 1

2

I suggest you drop the datareader.

Drag an SQLDataSource onto the page and configure it with your query. It will give you reading/updating without writing any code at all.

Sign up to request clarification or add additional context in comments.

2 Comments

No, the OP is using Access and (most likely) WinForms.
My Apologies - Henk is correct. I saw DataGrid and thought GridView. Been doing too many WebForms recently.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.