Question

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);

No correct solution

OTHER TIPS

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

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top