Click here to Skip to main content
15,888,610 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have 3 column in my table ID,Status,feedback.Id is identity,status value bydefault is false and I have to insert value of feedback using entity framework in n-tier arch.

I made 3 classes as

BO
C#
namespace problemvisa
{
    public class Bo
    {
        private int id;

        public int Id
        {
            get { return id; }
            set { id = value; }
        }
        private string status;

        public string Status
        {
            get { return status; }
            set { status = value; }
        }
        private string feedback;

        public string Feedback
        {
            get { return feedback; }
            set { feedback = value; }
        }


2-DAL
 public class DAL
    {
        public bool insert(Bo aa)
        {
            if (aa.Equals(null))
            {
                return false;
            }
            else
            {
                using (problemEntities1 context = new problemEntities1())
                {
                    Table1 tt = new Table1();
                     context.AddToTable1(tt);
                     context.SaveChanges();
                }
                return true;



3.BAL


 public class BAL
    {
        public bool insert(Bo ss)
        {
            DAL dd = new DAL();
            if (dd.insert(ss))
            {
                return true;
            }
            else
            {
                return false;
            }
        }


IN aspx form



 protected void Button1_Click(object sender, EventArgs e)
        {
            
            Bo aa = new Bo();
            aa.Status = "false";
            aa.Feedback = TextBox1.Text;
            BAL ss = new BAL();
            ss.insert(aa);
        }
    }



One error is coming i.e.Cannot insert the value NULL into column 'feedback', table 'problem.dbo.Table1'; column does not allow nulls. INSERT fails.
The statement has been terminated.
Posted

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