vivek_nz76
Member
- Joined
- Sep 20, 2005
- Messages
- 8
- Programming Experience
- 3-5
Hi I am adding the dataset to the collection object. It fails here
Public Sub Add(ByVal oUser As CUser)
_userArray.Add(oUser)
End Sub
Says Object reference not set to an instance of an object
PublicFunction GetUserDetail() As CDbUsers
' Create the Database object, using the default database service. The
' default database service is determined through configuration.
Dim db As Database = DatabaseFactory.CreateDatabase()
Dim sqlCommand AsString = "Select * From SecureUser"
Dim dbCommandWrapper As DBCommandWrapper = db.GetSqlStringCommandWrapper(sqlCommand)
Dim userDataSet As DataSet = Nothing
Dim oUser AsNew CUser
Dim userCol AsNew CDbUsers
userDataSet = db.ExecuteDataSet(dbCommandWrapper)
ForEach row As DataRow In userDataSet.Tables(0).Rows
oUser.UserID = row.Item("UserID")
oUser.FName = row.Item("FirstName")
oUser.LName = row.Item("LastName")
oUser.Username = row.Item("Username")
oUser.Password = row.Item("Password")
userCol.Add(oUser) --WHERE I AM CALLING THE ABOVE METHOD
Next
Return userCol
EndFunction
Public Sub Add(ByVal oUser As CUser)
_userArray.Add(oUser)
End Sub
Says Object reference not set to an instance of an object
PublicFunction GetUserDetail() As CDbUsers
' Create the Database object, using the default database service. The
' default database service is determined through configuration.
Dim db As Database = DatabaseFactory.CreateDatabase()
Dim sqlCommand AsString = "Select * From SecureUser"
Dim dbCommandWrapper As DBCommandWrapper = db.GetSqlStringCommandWrapper(sqlCommand)
Dim userDataSet As DataSet = Nothing
Dim oUser AsNew CUser
Dim userCol AsNew CDbUsers
userDataSet = db.ExecuteDataSet(dbCommandWrapper)
ForEach row As DataRow In userDataSet.Tables(0).Rows
oUser.UserID = row.Item("UserID")
oUser.FName = row.Item("FirstName")
oUser.LName = row.Item("LastName")
oUser.Username = row.Item("Username")
oUser.Password = row.Item("Password")
userCol.Add(oUser) --WHERE I AM CALLING THE ABOVE METHOD
Next
Return userCol
EndFunction