Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: Framework entity
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
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 3-Mar-13 21:50pm

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

  Print Answers RSS
0 OriginalGriff 490
1 Maciej Los 305
2 Richard MacCutchan 270
3 Mathew Soji 220
4 BillWoodruff 210
0 OriginalGriff 8,834
1 Sergey Alexandrovich Kryukov 7,477
2 DamithSL 5,689
3 Maciej Los 5,329
4 Manas Bhardwaj 4,986


Advertise | Privacy | Mobile
Web04 | 2.8.1411028.1 | Last Updated 4 Mar 2013
Copyright © CodeProject, 1999-2014
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