Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: ASP.NET
Hi
I am write some code.this is To log in the customer then find customer all data in another page.but execute code error is Object reference not set to an instance of an object. so Please help me the solve this problem....
Posted 2-Jul-12 19:56pm
Comments
Vani Kulkarni at 3-Jul-12 1:04am
   
Please post your code, also mark the exact line where you are getting this error.
Arundhati Mohanty at 17-Dec-13 1:25am
   
Hi i am workin in Silverlight5,VisualStudio2010,as i am new to it am not able to solve the problem,as i think i hv written all The codes correctly.
ERROR:
at SaveButton_Click(Object sender, RoutedEventArgs e) at System.Windows.Controls.Primitives.ButtonBase.OnClick() at System.Windows.Controls.Button.OnClick() at System.Windows.Controls.Primitives.ButtonBase.OnMouseLeftButtonUp(MouseButtonEventArgs e) at System.Windows.Controls.Control.OnMouseLeftButtonUp(Control ctrl, EventArgs e)
Rahul Rajat Singh at 3-Jul-12 2:56am
   
Show us the line where this exception is coming and we will try to find the null object for you.
Maria Norbert at 20-Dec-13 0:43am
   
Hey Guyz...

Me to getting the Same error..

But when i rebuild Website the error Solved..

The Same thing happens to my Team Mates.. Please Help to resolve this...
padiharprem at 25-Sep-14 7:23am
   
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.
padiharprem at 25-Sep-14 7:25am
   
How open formview edit mode base on click edit button on gridview

Please solution provided to me i am try it but i am not get success
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

Its a normal error what you are getting.

Please provide the code for proper solution.

Hint: I your code there is some object which is NULL. and you will be trying to read some property value of that object.

This is the reason for the Object reference not set to an instance of an object.
  Permalink  
Comments
Member 10135342 at 3-Jul-13 6:09am
   
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using System.Configuration;
using System.Data.SqlClient;
using UserDetails;

namespace RegisterUser
{
public static class RegUser
{

public static int insert(user obj)
{

string cnstr = ConfigurationManager.ConnectionStrings["myCnstr"].ToString();
using (SqlConnection cn = new SqlConnection(cnstr))

here i got

Object reference not set to an instance of an object.



{
cn.Open();
string myquery = "INSERT INTO Registration(Name,address,EmailAddress,Password,Phoneno,Answer) Values (@Name,@address,@emailaddress,@Password,@Phoneno,@Answer)";
using (SqlCommand cmd = new SqlCommand(myquery, cn))
{
cmd.Parameters.AddWithValue("@Name", obj.Name);
cmd.Parameters.AddWithValue("@address", obj.address);
cmd.Parameters.AddWithValue("@emailaddress", obj.EmailAdress);
cmd.Parameters.AddWithValue("@Password", obj.Password);
cmd.Parameters.AddWithValue("@Phoneno", obj.PhoneNo);
cmd.Parameters.AddWithValue("@Answer", obj.Answer);

return cmd.ExecuteNonQuery();
// "INSERT INTO Registration(Name,address,Emailid,PhoneNum)( VALUES(@Name,@address,@emailaddress,@Password,@Phoneno,@Answer)

}
}
}
}
}
2irfanshaikh at 3-Jul-13 11:14am
   
Please send your config file
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

When ever you try to retrieve data from a Null object you will get this error. Before retrieving the data from any object check for NULL.
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 3

Please put your code here and say on which line u get that error..
and simply there are null value and u just try to get that property which value is null so you get that error.
  Permalink  
Comments
mohitpahwa1 at 24-Jan-13 0:35am
   
you can add if condition like
if(your object !=null)
{
execute the code
}
Divyanshu Saini at 26-Jan-14 4:59am
   
I'm getting this same erron in my code
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 8

cd = root.SelectSingleNode("/Customers/Customer[CustomerID ='" + this.TextBox11.Text + "']");
has aerror
object reference not set to an instance of an object
please tell me solution
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 9

Just Check your connection string
that you have properly initialized your connection
and your connection is open when you trying to save or retrive data
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 11

This is a common error it happens to me all the time.
The solution is simple but depends on the code please supply the code to know what is wrong.
Note: Most times the solution is to find the object that is causing the problem (which the compiler will point out) and recreate it in the beginning of your function.
  Permalink  
Comments
Member 10742722 at 19-Apr-14 7:44am
   
protected void page_load(object sender,EventArgs e)
{
TextBox1.focus();
}
object reference not set to an instance of an object
plz tell me the solution

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 Sergey Alexandrovich Kryukov 453
1 Sascha Lefévre 370
2 Abhinav S 170
3 Richard Deeming 160
4 Maciej Los 150
0 Sergey Alexandrovich Kryukov 7,096
1 OriginalGriff 6,395
2 Maciej Los 2,782
3 Abhinav S 2,732
4 Peter Leow 2,694


Advertise | Privacy | Mobile
Web01 | 2.8.150414.1 | Last Updated 16 Apr 2014
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100