sreekanth v

sreekanth v

  • NA
  • 51
  • 0

Error while inserting a record

Sep 6 2011 11:20 PM

I am getting error like this

String or binary data would be truncated.
The statement has been terminated.

here is the my code

in DAL.cs
 
public bool insertemployee(Cmp c)
       
{
           
EmployeesDataContext db = new EmployeesDataContext();
           
Employee emp=new Employee();
            emp
.empid = c.empid;
            emp
.empname = c.empname;
            emp
.salary = c.salary;
            emp
.hiredate = c.hiredate;
            db
.Employees.InsertOnSubmit(emp);
            db
.SubmitChanges();
           
return true;
       
}

in Default.aspx.cs
 
protected void btnsubmit_Click(object sender, EventArgs e)
       
{
           
Cmp c = new Cmp();
           
Employe emp = new Employe();
            c
.empid = Convert.ToInt32(txtempid.Text);
            c
.empname = txtempname.ToString();
            c
.hiredate = Convert.ToDateTime(txthiredate.Text);
            c
.salary = Convert.ToInt32(txtsalary.Text);
            emp
.insertemployee(c);
       
}

Answers (2)