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.