Hi Thearon, TQ very much for your reply.
I figured that the error occured because there's no items in the TimeSheets and TimeSheetItems table. Have I missed out on the steps for creating them before chapter12?
1)The code is from chapter11 and 12
2)The Form is Timesheet.
vb
3)The steps is to create a project and group in the admin form. Then add 3 roles and 4 users as mentioned in page 349. Then quit and run the application but log in as the user created. The program will try to show the Timesheet but quit on the method below.
4)The error occured at the method below
Private Sub LoadTimeSheet(ByVal WeekEndingDate As ComboBox)
'Clear previous bindings
grdTimeSheet.DataSource = Nothing
grdTimeSheet.DataMember = String.Empty
'Initialize a new instance of the business logic component
objTimeSheets = New WroxBusinessLogic.WBLTimeSheets( _
strCompany, strApplication)
'Get the timesheet for the user
objTimeSheetDS = objTimeSheets.GetTimeSheet( _
New Guid(strUserID), WeekEndingDate.SelectedItem)
'Set the DataView object with the data from the DataSet
objTimeSheetDV = New DataView(objTimeSheetDS.Tables("TimeSheet"))
'Initialize a new DataRowView object
Dim objDataRowView As DataRowView = objTimeSheetDV.AddNew
'Set the values in the columns
objDataRowView("ProjectName") = "Total Hours"
'Calculate and set the total hours for Monday
intTotal = 0
For intIndex = 0 To objTimeSheetDS.Tables("TimeSheet").Rows.Count - 1
Error here ---> intTotal += objTimeSheetDS.Tables( _
"TimeSheet").Rows(intIndex).Item("MondayHours" )
........ End Sub
Thanks,
HGC