Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Update with column name by parameter
- DataTable dt = new DataTable();
- // Here I fill my datatable
- for (int i = 0; i < dt.Rows.Count; i++)
- {
- for (int j = 0; j < dt.Columns.Count; j++)
- {
- string columnsname = dt.Rows[i][dt.columns[j].toString()].toString();
- SqlCommand comando = new SqlCommand();
- comando.commandText = "UPDATE Sales.Store SET @columnname = @demographics where id = @id";
- comando.Parameters.Add(new SqlParameter("@columnname", columname));
- comando.Parameters.Add(new SqlParameter("@dados2", dados2));
- comando.ExecuteNonQuery();
- comando.Clear();
- comando.Dispose()
- }
- }
Add Comment
Please, Sign In to add comment