Click here to Skip to main content
15,907,001 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i have written the following code in my business logic and it is producing some error like are u missing using directive or assembly function. But i have check the references for many time and not able to get why this error is coming. the following is my BAL code:
using Datalgc;
using DL;
                 // In this layer we have to declare prop.,methods like if i want to insert just create a function/method for inserting values and call it on button click .cs file

namespace Buss
{
    public class BusinessLogic
    {
        GenralFunction gf = new GenralFunction();
       
        public class property
        {
            private string _Name;
            private int _DOB;
            private string _Add;
            private int _Phno;
            private string _Country;
            private string _State;
            private string _Distt;

            public string Name
            {
                get { return _Name; }
                set { _Name = value; }
            }
            public int DOB
            {
                get { return _DOB; }
                set { _DOB = value; }
            }
            public string Add
            {
                get { return _Add; }
                set { _Add = value; }
            }
            public int Phno
            {
                get { return _Phno; }
                set { _Phno = value; }
            }
            public string Country
            {
                get { return _Country; }
                set { _Country = value; }
            }
            public string State
            {
                get { return _State; }
                set { _State = value; }
            }
            public string Distt
            {
                get { return _Distt; }
                set { _Distt = value; }
            }
       }
        public DataTable userdetails()                                    // my table name in database
        {
             DataTable dt = new DataTable();
             dt = gf.Filldatatablevalue(null, "spuserdetails", dt,null);
            return dt;
        }
        public int Insert()
        {
            int result = 0;
              SqlParameter[] parameters = new SqlParameter[7];
            parameters[0] = new SqlParameter("@Name", SqlDbType.VarChar, 4) 
            { Value = Name };
            parameters [1] = new SqlParameter("@DOB", SqlDbType.Datetime, 2)
            { Value = DOB };
            parameters[2] = new SqlParameter("@Addr", SqlDbType.VarChar, 3) 
            { Value = Addr };
           parameters[3] = new SqlParameter("@phn", SqlDbType.Int, 2) 
           { Value = phn};
            parameters[4] = new SqlParameter("@Country", SqlDbType.VarChar, 2) 
            { Value = Country };
            parameters[5] = new SqlParameter("@State", SqlDbType.VarChar, 70) 
            { Value = State };
            parameters[6] = new SqlParameter("@City", SqlDbType.VarChar, 70) 
            { Value = City };
            result = gf.UpdateData(parameters, "spuserdetails");
            return 0;
        }
      
    }
        
}

also
Value = Name
and etc in insert method are showing error that Name does not exist in the current context. also after adding the namespace of BAL (here Buss to my codebehind file i m not able to use the properties. what i have done in .cs file is as follows:
BusinessLogic obj = new BusinessLogic();
and with this object i want to assingn values to the properties but can't. Why? Help me .Thanks.
Posted
Updated 19-Jun-13 1:58am
v2
Comments
[no name] 19-Jun-13 8:05am    
1. You need to include System.Data
2. Because for some strange reason you have wrapped your class properties in a separate class and that is why Name does not exist in that context
3. Also because you have wrapped your properties in a separate class.

1 solution

1. You need to include System.Data
2. Because for some strange reason you have wrapped your class properties in a separate class and that is why Name does not exist in that context
3. Also because you have wrapped your properties in a separate class.

And to answer the unasked question:
Because you do not have an "Addr" property, you named it "Add". Same with the other properties that can't be found.
 
Share this answer
 

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