Hello,
I am currently new to C# and am working with a large project. I need to loop through a datagrid, take the user-entered data, and insert it into a database table so I can pull the data from other forms. It is supposed to work when the user clicks the submit button to save all entered info... Not sure if the code I have so far is correct:
private void btnSubmit_Click(object sender, EventArgs e)
{
DataTable dtDataTableName = new DataTable("TABLENAME");
dataGridView.DataSource = dtDataTableName;
foreach (DataRow dataRow in dtDataTableName.Rows)
{
foreach (DataColumn dataColumn in dtDataTableName.Columns)
{
StringBuilder sql = new StringBuilder();
sql.Append("Insert into TABLENAME table");
}
}
Thanks for any help!:)