I select * from
an Excel spreadsheet into DataTable
dt
. I want to take those values and update the SQL table. The SQL table exists because of a manual import to SQL from the original Excel spreadsheet, has a primary key set. The user updates the excel sheet and I need to update the SQL values. I am setting the dt.RowState
to modified in an effort to invoke the update. I get no error but the SQL table does not update. Previous test show my SQL permissions and connection is good, I can modify the table.
connectionToSQL = new SqlConnection(SQLConnString);
connectionToSQL.Open();
var cmd = new SqlCommand("SELECT * FROM TAGS$",connectionToSQL);
var da = new SqlDataAdapter(cmd);
var b = new SqlCommandBuilder(da);
foreach (DataRow r in dt.Rows)
{
r.SetModified();
}
da.Update(dt);