I am having trouble updating the database from a dataset. The data is inserted into the datatable in the dataset correctly and I can see it in a datagridview, but when I look at the database the columns have not been added

This is my code below:

TimeSpan timeDif = dateToSet.Subtract(dateInTable);
int timeDifference = (int)timeDif.Days;

for (int i = 0; i < timeDifference; i++)
{
      DataColumn columnToAdd = new DataColumn(dateInTable.AddDays(i + 1).ToShortDateString());
      Program.pDiResourcesDataSet.WorkingProjects.Columns.Add(columnToAdd);
      Program.WorkingProjectsA.Update(Program.pDiResourcesDataSet.WorkingProjects);
}

Program.pDiResourcesDataSet.AcceptChanges();
Program.WorkingProjectsA.Update(Program.pDiResourcesDataSet);

没有正确的解决方案

其他提示

As rene said, you cannot add columns with dataadapter, rather use separate DDL statement to carry out the DDL operations, and use dataadapter to manipulate the records

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top