Reputation: 261
I am trying to update some field in my data table. While using the given below code shows one error. Help me to find a proper solution. Thank you.
Code:
ShadingAnalysisDataSetTableAdapters.tbl_AutoAssignJrEngineersTeamTableAdapter tm;
tm = new ShadingAnalysisDataSetTableAdapters.tbl_AutoAssignJrEngineersTeamTableAdapter();
DataTable dt = new DataTable();
dt = tm.UpdateTeam(AssignedTeam,userName,DateTime.Now,ID); // error popup here
SQL:
UPDATE tbl_AutoAssignJrEngineersTeam
SET Assigned_Team = @Assigned_Team,
Updated_By = @Updated_By,
Updated_Date = @Updated_Date
WHERE (Id = @Id)
DataBase:
Upvotes: 2
Views: 4795
Reputation: 460288
The TableAdapter
-method returns an int
which is the count of affected records, so how many records were updated. But you are assigning it to a DataTable
variable.
int updatedRows = tm.UpdateTeam(AssignedTeam,userName,DateTime.Now,ID);
You either have to
GetData
- or Fill(dt)
methods from the TableAdapter tm.Update(modifiedDataTable)
instead which will execute the UpdateCommand
of the adapater for every row with RowState=Modified
.Upvotes: 4