Quantcast
Channel: Forum Getting started with SQL Server
Viewing all articles
Browse latest Browse all 7129

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

$
0
0

hello any buddy here please reply me it's argent. 

   I am developing an asp.net application using linq , the back end is sql server 2008 r2.

Whenever I try to insert a record I am receiving this "error String or binary data would be truncated. The statement has been terminated."

I Change the datatype to varchar(Max) and I can insert data from Microsoft Sql server Management studio and everything works correctly .

But when I tried to insert from asp.net page I receive the error mentionned above.

For your information when I am click save page submit change() error is

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class Register : System.Web.UI.Page
{
    DataClassesDataContext dc = new DataClassesDataContext();
    Registration regi = new Registration();
    protected void Page_Load(object sender, EventArgs e)
    {

    }
    protected void btnSubmit_Click(object sender, EventArgs e)
    {
        //   try
        //{


       
            regi.UserName = txtuname.Text;
            regi.Address = txtAddress.Text;
            regi.FirstName = txtFirstName.Text;
            regi.Password = txtPass.Text;
            regi.ConfirmPassword = txtcpass.Text;
            regi.Email = txtEmail.Text;
            regi.Contact = txtContact.Text;
            regi.LastName = txtLname.Text;
           
            regi.DOB = Convert.ToDateTime(txtDOB.Text);
           
            
            regi.Status = 1;
            regi.Roll_Id = 2;
           
            dc.Registrations.InsertOnSubmit(regi);
            dc.SubmitChanges();
                      Response.Redirect("~/login.aspx");

       // }
       // catch (Exception ex)
       //{
       //    Response.Redirect(ex.Message);
       //}
    }
    
}


Viewing all articles
Browse latest Browse all 7129

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>