You must Sign In to post a response.
  • Category: SQL Server

    Problem occured in stored procesure

    create procedure [dbo].[inserregb]
    @id int

    insert into Registration values( '"+TextBox1.Text+"' ,'" + TextBox2.Text + "','"+ddlcountry.SelectedItem.Value.ToString()+"','" +ddlstate.SelectedItem.Value.ToString() + "','" + DropDownList5.SelectedItem.Value.ToString() + "','" + DropDownList6.SelectedItem.Value.ToString() + "','" + CheckBox1.Text + "','" + TextBox3.Text + "','" + TextBox4.Text + "','" + TextBox5.Text + "','" + TextBox6.Text + "')
    //when i exec itcoming command executed successfully
    //when i write like exec inserregc @id=1
    Msg 8152, Level 16, State 4, Procedure inserregc, Line 10
    String or binary data would be truncated.
    The statement has been terminated.
    so any one help me
  • #753040
    You have to pass the textbox values to this stored procedure using input parameters. As per your stored procedure, It will insert the value to the Registration table like TextBox1.Text writing the value on the TextBox1. Please change the code and pass the parameter into the values part.
    Please mark this as Answer, if this helps

    Alwyn Duraisingh.M 
    << Database Administrator >>
    Jesus saves! The rest of us better make backups...

  • #753043
    it looks like the data you are passing to one of the columns is exceeding the length of the column or you are not passing the correct data type value in one of the columns. Please compare the data type of the value you are passing to the column data type in the database or make sure that you are passing the value in correct format.
    Miss. Jain
    Microsoft Certified Technology Specialist in .Net

  • #753048

    It's looks like a datatype issue actually the column datatype is in byte format but while passing the value you are passing string type that is the reason it's throwing this error. You need to pass exact type what you are declare at the time of table creation.

    Give respect to your work, Instead of trying to impress your boss.

    Blog :

  • #753050
    Refer the Below SQL / C# codes

    CREATE PROCEDURE Inserregb @name VARCHAR(200),
    @Place VARCHAR(200),
    @email VARCHAR(200),
    @ID INT output
    VALUES ( @name,
    @email )

    SELECT @ID = Scope_identity()




    SqlConnection conn = new SqlConnection("your-connect-string"))
    SqlCommand cmd = conn.CreateCommand()
    cmd.CommandText = @"dbo.Inserregb" ;
    cmd.CommandType = CommandType.StoredProcedure ;
    cmd.Parameters.AddWithValue( "@name" , TextBox1.Text) ;
    cmd.Parameters.AddWithValue( "@Place" , TextBox2.Text ) ;
    cmd.Parameters.AddWithValue( "@email" , TextBox3.Text ) ;
    conn.Open() ;
    cmd.ExecuteNonQuery() ;
    conn.Close() ;

  • #753055
    Is this a stored procedure? from where you are passing the values for textbox? This is not the correct way to create the Stored procedure. Please check the code once again.

    Also please post the complete stored procedure code from your database. So that we will get to know how it is stored in the database.

    Asheej T K

  • #761044

    if you saw this error

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

    your datatype is small compare from your request

    for ex: varchar(2) but your input string this
    dotnetspider so how can insert more than 2 characters so if you saw this error.

    Name : Dotnet Developer-2015
    Email Id :

    'Not by might nor by power, but by my Spirit,' says the LORD Almighty.

  • Sign In to post your comments