Click here to Skip to main content
15,890,438 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
C#
DataAccessLayer:

public string  REPEATED_NAME (Add_SupplierPL obj)
        {

            string  str = "SELECT S_NAME FROM SUPPLIER WITH (NOLOCK) WHERE UNIT='" + obj.UNIT + "' AND COMPANY='"+ obj.COMPANY +"' AND S_NAME='" + obj.SUPPLIERNAME + "'";
            obj.SUPPLIERNAME = SqlHelper.ExecuteScalar(SqlCon, CommandType.Text, str).ToString();
           if(obj.SUPPLIERNAME=="")
            {
                return "0";
            }
            else
            {
                return obj.SUPPLIERNAME;
            }
}



the error is"Object reference not set to an instance of an object",
it can't return the null data plz hlep me,,
Posted
Updated 27-Oct-13 3:30am
v4
Comments
Mahesh Bailwal 27-Oct-13 2:40am    
what error are you getting?
Member 9959371 27-Oct-13 9:29am    
I was getting error "Object reference not set to an instance of an object"

1 solution

Do the following:
C#
obj.SUPPLIERNAME = "" + SqlHelper.ExecuteScalar(SqlCon, CommandType.Text, str);
 
Share this answer
 
Comments
Member 9959371 27-Oct-13 9:22am    
it does not work,, thowr the same error,,plz send me correct code
Mehdi Gholam 27-Oct-13 9:25am    
Put a breakpoint on your code and see where you are getting the null.
Member 9959371 27-Oct-13 9:34am    
iam using to breskpoint in that code,, the error is "Object reference not set to an instance of an object"
Mehdi Gholam 27-Oct-13 9:35am    
Which object is null?
Member 9959371 27-Oct-13 9:40am    
the object is enter the data in presentationlayer(textbox),is null data,, plz ,corrct code send me

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900