Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Visual Basic > VB.NET 1.0 > BOOK: Beginning VB.NET Databases
Password Reminder
Register
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
BOOK: Beginning VB.NET Databases
This is the forum to discuss the Wrox book Beginning VB.NET Databases by Thearon Willis; ISBN: 9780764568008
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Beginning VB.NET Databases section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old January 23rd, 2005, 01:11 PM
Registered User
 
Join Date: Jan 2005
Location: , , .
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default usp_SelectTimeSheet

While in Chp 12 I received this error while trying to log in as role user
An unhandled exception of type 'System.InvalidCastException' occurred in microsoft.visualbasic.dll

Additional information: Operator is not valid for type 'Integer' and type 'DBNull'.

Debugger is pointing to this
error line

  intTotal = intTotal + objTimeSheetDS.Tables( _
                "TimeSheet").Rows(intIndex).Item("MondayHours" )

I think it has got something to do with the usp_SelectTimeSheet. Anyone out there has any clues.

Reply With Quote
  #2 (permalink)  
Old January 24th, 2005, 06:10 AM
Thearon's Avatar
Wrox Author
 
Join Date: Dec 2003
Location: Fuquay Varina, NC, USA.
Posts: 396
Thanks: 0
Thanked 8 Times in 8 Posts
Default

Hi,

Can you be a little more specific on where the error occurred? Please list the component, class, and method where the error occurred and any circumstances leading up to the error.

Thanks,
Thearon
Reply With Quote
  #3 (permalink)  
Old January 24th, 2005, 07:17 AM
Registered User
 
Join Date: Jan 2005
Location: , , .
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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


Reply With Quote
  #4 (permalink)  
Old January 25th, 2005, 07:22 AM
Thearon's Avatar
Wrox Author
 
Join Date: Dec 2003
Location: Fuquay Varina, NC, USA.
Posts: 396
Thanks: 0
Thanked 8 Times in 8 Posts
Default

HGC,

The timesheet data should be created in the Data Access component if it does not retrieve any existing data. Please verify step 7 on page 427 in Chapter 12.

Thearon
Reply With Quote
  #5 (permalink)  
Old January 27th, 2005, 02:32 AM
Registered User
 
Join Date: Jan 2005
Location: , , .
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi Thearon,

Thx for the feedback. I finally found the issue was typo error on my part for the TimeSheet table and also select case Group Project. Now the program works fine.

Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off




All times are GMT -4. The time now is 02:44 AM.


Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.