Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Visual Basic > VB.NET 1.0 > BOOK: Beginning VB.NET Databases
|
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 software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old June 10th, 2005, 04:48 PM
Registered User
 
Join Date: Dec 2003
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Default Object reference not set to an instance of an obj

Hi,

Chapter 12
----------

I have problem in chapter 12. I cannot display Roles as in Figure 12-1 (Page 412) and Users in Fig 12-2. I get error message "Object reference not set to an instance of an object". Please note I am using SQL Server 2000 - Developer edition and Microsoft Visual Studio .NET 2003.

A code snippets are as below:

(1) WDARoles.vb
---------------------------------------------------------------------------
    Public Function GetRoles() As DataSet
        Try
            GetRoles = New DataSet
            MyBase.SQL = "usp_SelectRoles"
            'Fill the DataSet
            MyBase.FillDataSet(GetRoles, "Roles")

        Catch ExceptionErr As Exception
            Throw New System.Exception(ExceptionErr.Message, _
            ExceptionErr.InnerException)

        End Try
    End Function
---------------------------------------------------------------------------
In the above case the message appears for the statement below:
            MyBase.FillDataSet(GetRoles, "Roles")
---------------------------------------------------------------------------

(2) Admin.vb
---------------------------------------------------------------------------
    Private Sub LoadUsers()
        'Declare variables
        Dim objListViewItem As ListViewItem

        'Initialize a new instance of the business logic component
        objUsers = New WroxBusinessLogic.WBLUsers( _
            strCompany, strApplication)

        Try

            'Get all roles in a DataSet object
            objUsersDS = objUsers.GetUsers()

            'Clear previous list
            lvwUsers.Items.Clear()

            'Process all rows
            For intIndex = 0 To objUsersDS.Tables("Users").Rows.Count - 1
                'Create a new listview item
                objListViewItem = New ListViewItem
                'Add the data to the listview item
                objListViewItem.Text = _
                    objUsersDS.Tables("Users").Rows(intIndex).Item("Lo ginName")
                objListViewItem.Tag = _
                    objUsersDS.Tables("User").Rows(intIndex).Item("Use rID")
---------------------------------------------------------------------------
The error message appears at the last line which is:

                objListViewItem.Tag = _
                    objUsersDS.Tables("User").Rows(intIndex).Item("Use rID")
---------------------------------------------------------------------------
Any help will be geatly appreciated.
 
Old June 13th, 2005, 04:00 AM
Thearon's Avatar
Wrox Author
 
Join Date: Dec 2003
Posts: 396
Thanks: 0
Thanked 8 Times in 8 Posts
Default

I'm a little confused as to the error you are getting as you are showing two unrelated snippets of code. I assume you are getting the "Object reference not set to an instance of an object" error on code snippet 1. In this case ensure that you have created the usp_SelectRoles stored procedure and that you are calling the GetRoles function to load the roles.

Thearon
 
Old June 13th, 2005, 02:44 PM
Registered User
 
Join Date: Dec 2003
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi,

Chapter 12
----------


Sorry for the confusion.

Initially "Object reference not set to an instance of an object" error message box is confronted at (1) WDARoles.vb( above ) where I respond with return for the button. The second time the error message box is encountered in (2) Admin.vb( above ).

Please note having downloaded, compiled and run. I do not have the above problem.

Many Thanks.

Narendra
 
Old June 14th, 2005, 03:59 AM
Thearon's Avatar
Wrox Author
 
Join Date: Dec 2003
Posts: 396
Thanks: 0
Thanked 8 Times in 8 Posts
Default

Narendra,

That's good. Now all you have to do is compare the code you downloaded with your code to determine the missing pieces.

Thearon
 
Old June 21st, 2005, 06:35 PM
Registered User
 
Join Date: Dec 2003
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thearon,

Thanks for your help.

Regards

Narendra





Similar Threads
Thread Thread Starter Forum Replies Last Post
Object refrence not set to an instance of an obj viral648 ASP.NET 1.0 and 1.1 Professional 1 January 2nd, 2007 01:11 PM
Object reference not set to an instance of an obj. Dwizz VB.NET 2002/2003 Basics 8 June 1st, 2005 08:28 AM
Object Reference is Not Set to an Instance of an O blackinwhite General .NET 4 February 1st, 2005 05:42 AM
Object reference not set to an instance... steelman BOOK: ASP.NET Website Programming Problem-Design-Solution 6 May 7th, 2004 02:03 AM
Object reference not set to an instance of an obje aac Classic ASP Databases 11 July 18th, 2003 03:23 PM





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