I’m trying to export actual cost from my SQL Server database to Microsoft Project. This code used to work, but after some tinkering to how the data is received – not to the data itself – I am experiencing a strange error.
This is the gist of my code, which hasn’t changed at all:
objAssignment = appProj.Application.ActiveProject.Tasks(intTASK_ID).Assignments.Add(ResourceID:=appProj.ActiveProject.Resources(strRES_ID).ID) ‘Assign Actual resource to the task
…
If dsExportDetail.Tables(0).Rows(intCounter).Item(2) Is DBNull.Value Then
dateAssign = Now()‘If there is no date, assign data to the current day
TSV = objAssignment.TimeScaleData(dateAssign, dateAssign, 28, 4) TSV.Add(dsExportDetail.Tables(0).Rows(intCounter).Item(3), 1)
Else
dateAssign = dsExportDetail.Tables(0).Rows(intCounter).Item(2)
‘Set the TSV date to the actual cost date from SQL Server
TSV = objAssignment.TimeScaleData(dateAssign, dateAssign, 28, 4)
Try TSV.Add(dsExportDetail.Tables(0).Rows(intCounter).Item(3), 1)
‘Add TSV data
Catch ex As System.Exception MsgBox(dsExportDetail.Tables(0).Rows(intCounter).Item(3))
EndTry
End If
Whereas this code used to properly spread the data across the dates provided, now the values are grouping into a single lump sum and placed at either or the beginning or the end of the project’s schedule. In other words, even if the actual cost looks like this:
$5000 on 1/1/2012
$300 on 1/2/2012
$500 on 1/3/2012
$200 on 1/4/2012
The value that is assigned is $6,000 at the end of the project (say, 6/7/2012)… or it may be assigned to the beginning of the project, whenever that day is.
Are the any ideas? Thank you very much.