Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. error String or binary data would be truncated.

error String or binary data would be truncated.

Scheduled Pinned Locked Moved ASP.NET
csharphelpasp-netannouncement
3 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • P Offline
    P Offline
    prateekfgiet
    wrote on last edited by
    #1

    hi i m using asp.net c# n i m trying to save data in to data base it give error at time of save code is cmd.CommandText = "select invoice_no from invoice where invoice_no=(select Max(invoice_no) from invoice)"; adp.Fill(ds, "dm"); foreach (DataRow dm in ds.Tables["dm"].Rows) { Label2.Text = dm["invoice_no"].ToString(); } Label2.Text = Convert.ToString( Convert.ToInt32(Label2.Text) + 1); // add in the table material incoming cmd.CommandText = "Select * from invoice"; adp.Fill(ds, "re"); dr = ds.Tables["re"].NewRow(); cb = new SqlCommandBuilder(adp); adp.Update(ds.Tables["re"]); dr = ds.Tables["re"].NewRow(); dr["invoice_no"] = Convert.ToString(l); //dr["enterby"] = Label64.Text; //ddlinby.SelectedIndex.ToString(); dr["po_no"] = TextBox2.Text; dr["dc_no"] = TextBox3.Text; dr["comp_name"] = TextBox4.Text; dr["comp_add"] = TextBox5.Text; dr["tin_no"] = TextBox42.Text; dr["total_vat"] = TextBox34.Text; dr["prod1"] = TextBox35.Text; dr["prod2"] = TextBox36.Text; dr["prod3"] = TextBox37.Text; dr["prod4"] = TextBox38.Text; dr["prod5"] = TextBox39.Text; dr["prod6"] = TextBox40.Text; dr["prod1_q"] = TextBox12.Text; dr["prod2_q"] = TextBox13.Text; dr["prod3_q"] = TextBox14.Text; dr["prod4_q"] = TextBox15.Text; dr["prod5_q"] = TextBox16.Text; dr["prod6_q"] = TextBox17.Text; dr["prod1_p"] = TextBox18.Text; dr["prod2_p"] = TextBox19.Text; dr["prod3_p"] = TextBox20.Text; dr["prod4_p"] = TextBox21.Text; dr["prod5_p"] = TextBox22.Text; dr["prod6_p"] = TextBox23.Text; dr["vat"] = TextBox31.Text; dr["total"] = TextBox30.Text; dr["price"] = TextBox33.Text; ds.Tables["re"].Rows.Add(dr); cmd.CommandText = "Select * from invoice"; cb = new SqlCommandBuilder(adp); adp.Update(ds.Tables["re"]); and error is String or binary data would be truncated.The statement has been terminated. at this line adp.Update(ds.Tables["re"]); pls help me

    S S 2 Replies Last reply
    0
    • P prateekfgiet

      hi i m using asp.net c# n i m trying to save data in to data base it give error at time of save code is cmd.CommandText = "select invoice_no from invoice where invoice_no=(select Max(invoice_no) from invoice)"; adp.Fill(ds, "dm"); foreach (DataRow dm in ds.Tables["dm"].Rows) { Label2.Text = dm["invoice_no"].ToString(); } Label2.Text = Convert.ToString( Convert.ToInt32(Label2.Text) + 1); // add in the table material incoming cmd.CommandText = "Select * from invoice"; adp.Fill(ds, "re"); dr = ds.Tables["re"].NewRow(); cb = new SqlCommandBuilder(adp); adp.Update(ds.Tables["re"]); dr = ds.Tables["re"].NewRow(); dr["invoice_no"] = Convert.ToString(l); //dr["enterby"] = Label64.Text; //ddlinby.SelectedIndex.ToString(); dr["po_no"] = TextBox2.Text; dr["dc_no"] = TextBox3.Text; dr["comp_name"] = TextBox4.Text; dr["comp_add"] = TextBox5.Text; dr["tin_no"] = TextBox42.Text; dr["total_vat"] = TextBox34.Text; dr["prod1"] = TextBox35.Text; dr["prod2"] = TextBox36.Text; dr["prod3"] = TextBox37.Text; dr["prod4"] = TextBox38.Text; dr["prod5"] = TextBox39.Text; dr["prod6"] = TextBox40.Text; dr["prod1_q"] = TextBox12.Text; dr["prod2_q"] = TextBox13.Text; dr["prod3_q"] = TextBox14.Text; dr["prod4_q"] = TextBox15.Text; dr["prod5_q"] = TextBox16.Text; dr["prod6_q"] = TextBox17.Text; dr["prod1_p"] = TextBox18.Text; dr["prod2_p"] = TextBox19.Text; dr["prod3_p"] = TextBox20.Text; dr["prod4_p"] = TextBox21.Text; dr["prod5_p"] = TextBox22.Text; dr["prod6_p"] = TextBox23.Text; dr["vat"] = TextBox31.Text; dr["total"] = TextBox30.Text; dr["price"] = TextBox33.Text; ds.Tables["re"].Rows.Add(dr); cmd.CommandText = "Select * from invoice"; cb = new SqlCommandBuilder(adp); adp.Update(ds.Tables["re"]); and error is String or binary data would be truncated.The statement has been terminated. at this line adp.Update(ds.Tables["re"]); pls help me

      S Offline
      S Offline
      saanj
      wrote on last edited by
      #2

      Hi, You are trying to save a value whose size is exceeded the maximum limit set for the column in which it is going to be saved. Check all values which you are setting in the datarow. Some value may be crossing their expected size. Regards Saanj

      Either you love IT or leave IT...

      1 Reply Last reply
      0
      • P prateekfgiet

        hi i m using asp.net c# n i m trying to save data in to data base it give error at time of save code is cmd.CommandText = "select invoice_no from invoice where invoice_no=(select Max(invoice_no) from invoice)"; adp.Fill(ds, "dm"); foreach (DataRow dm in ds.Tables["dm"].Rows) { Label2.Text = dm["invoice_no"].ToString(); } Label2.Text = Convert.ToString( Convert.ToInt32(Label2.Text) + 1); // add in the table material incoming cmd.CommandText = "Select * from invoice"; adp.Fill(ds, "re"); dr = ds.Tables["re"].NewRow(); cb = new SqlCommandBuilder(adp); adp.Update(ds.Tables["re"]); dr = ds.Tables["re"].NewRow(); dr["invoice_no"] = Convert.ToString(l); //dr["enterby"] = Label64.Text; //ddlinby.SelectedIndex.ToString(); dr["po_no"] = TextBox2.Text; dr["dc_no"] = TextBox3.Text; dr["comp_name"] = TextBox4.Text; dr["comp_add"] = TextBox5.Text; dr["tin_no"] = TextBox42.Text; dr["total_vat"] = TextBox34.Text; dr["prod1"] = TextBox35.Text; dr["prod2"] = TextBox36.Text; dr["prod3"] = TextBox37.Text; dr["prod4"] = TextBox38.Text; dr["prod5"] = TextBox39.Text; dr["prod6"] = TextBox40.Text; dr["prod1_q"] = TextBox12.Text; dr["prod2_q"] = TextBox13.Text; dr["prod3_q"] = TextBox14.Text; dr["prod4_q"] = TextBox15.Text; dr["prod5_q"] = TextBox16.Text; dr["prod6_q"] = TextBox17.Text; dr["prod1_p"] = TextBox18.Text; dr["prod2_p"] = TextBox19.Text; dr["prod3_p"] = TextBox20.Text; dr["prod4_p"] = TextBox21.Text; dr["prod5_p"] = TextBox22.Text; dr["prod6_p"] = TextBox23.Text; dr["vat"] = TextBox31.Text; dr["total"] = TextBox30.Text; dr["price"] = TextBox33.Text; ds.Tables["re"].Rows.Add(dr); cmd.CommandText = "Select * from invoice"; cb = new SqlCommandBuilder(adp); adp.Update(ds.Tables["re"]); and error is String or binary data would be truncated.The statement has been terminated. at this line adp.Update(ds.Tables["re"]); pls help me

        S Offline
        S Offline
        samMaster
        wrote on last edited by
        #3

        You have to check your input data. I think if you read a design pattern you can do this on better way. Say! your code is really horrible to understand. You have to try to use classes and generic collections if you want to manage your code. But if you check your input data, you can find the wrong input data type or data length. Good luck!!!

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups