Object reference not set to an instance of an object.

Data Access Application Blocks Forum

Object reference not set to an instance of an object.

Postby shantha05 on Mon Dec 19, 2005 8:25 pm

Object reference not set to an instance of an object.

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.NullReferenceException: Object reference not set to an instance of an object.

This is the error i am getting when tried to use following code in my asp.net application

Dim oEmployees As New CMSSol.Employees

oEmployees.LoadByPrimaryKey(1)

Response.Write(oEmployees.LastName)

I have a record in the table for EmployeeId=1

Any Suggestions?????
shantha05
Staff Sergent
 
Posts: 32
Joined: Mon Dec 19, 2005 8:20 pm

Re: Object reference not set to an instance of an object.

Postby mgnoonan on Mon Dec 19, 2005 9:11 pm

Yes, try this code instead which should give you more information:

Code: Select all
   Dim oEmployees As New CMSSol.Employees

   If oEmployees.LoadByPrimaryKey(1) Then
      Response.Write(oEmployees.LastName)
   Else
      Response.Write(oEmployees.ErrorMessage)
   End If


If ErrorMessage is blank, then no rows were loaded and no errors occurred.
Matt Noonan
EasyObjects.NET - The O/RM for the Enterprise Library
http://www.easyobjects.net
User avatar
mgnoonan
Expert
 
Posts: 1019
Joined: Tue Sep 14, 2004 3:17 am
Location: Springboro, OH

Login failed for user 'WLCDO55510\\ASPNET'

Postby shantha05 on Mon Dec 19, 2005 9:51 pm

I get the following error message

Login failed for user 'WLCDO55510\\ASPNET'

How to proceed further????
shantha05
Staff Sergent
 
Posts: 32
Joined: Mon Dec 19, 2005 8:20 pm

problem solved

Postby shantha05 on Mon Dec 19, 2005 10:02 pm

I have solved the problem

I have created the login in MSDE and gave read permissions and it solved the problem

Thanks a lot.
shantha05
Staff Sergent
 
Posts: 32
Joined: Mon Dec 19, 2005 8:20 pm

Postby mgnoonan on Mon Dec 19, 2005 10:07 pm

Glad you got it resolved. 8)
Matt Noonan
EasyObjects.NET - The O/RM for the Enterprise Library
http://www.easyobjects.net
User avatar
mgnoonan
Expert
 
Posts: 1019
Joined: Tue Sep 14, 2004 3:17 am
Location: Springboro, OH


Return to EasyObjects.NET (Microsoft Enterprise Library)

Who is online

Users browsing this forum: No registered users and 1 guest

cron