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. General Programming
  3. C#
  4. Problem in Dataadapter, sometimes its working and sometimes its showing error pls help

Problem in Dataadapter, sometimes its working and sometimes its showing error pls help

Scheduled Pinned Locked Moved C#
helpannouncement
4 Posts 4 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.
  • A Offline
    A Offline
    amaankhan
    wrote on last edited by
    #1

    Error "String or Binary data would be truncated. The Statement has been terminated" error on code >>>>>> public static bool SaveVisitor(string id,string n, string c, decimal p, string e,string a, string city, string country) { drow = ds.Tables[0].NewRow(); drow[0] = id; drow[1] = n; drow[2] = c; drow[3] = p; drow[4] = e; drow[5] = a; drow[6] = city; drow[7] = country; ds.Tables[0].Rows.Add(drow); vda.InsertCommand = vcb.GetInsertCommand(); int res = vda.Update(ds.Tables[0]); // showing error if (res > 0) { System.Windows.Forms.MessageBox.Show("Visitor Details Added"); return true; } else return false; }

    N J P 3 Replies Last reply
    0
    • A amaankhan

      Error "String or Binary data would be truncated. The Statement has been terminated" error on code >>>>>> public static bool SaveVisitor(string id,string n, string c, decimal p, string e,string a, string city, string country) { drow = ds.Tables[0].NewRow(); drow[0] = id; drow[1] = n; drow[2] = c; drow[3] = p; drow[4] = e; drow[5] = a; drow[6] = city; drow[7] = country; ds.Tables[0].Rows.Add(drow); vda.InsertCommand = vcb.GetInsertCommand(); int res = vda.Update(ds.Tables[0]); // showing error if (res > 0) { System.Windows.Forms.MessageBox.Show("Visitor Details Added"); return true; } else return false; }

      N Offline
      N Offline
      nagendrathecoder
      wrote on last edited by
      #2

      amaankhan wrote:

      sometimes its working and sometimes its showing error

      At the time of error, trace the values going into dataset and see if something is wrong with values.

      1 Reply Last reply
      0
      • A amaankhan

        Error "String or Binary data would be truncated. The Statement has been terminated" error on code >>>>>> public static bool SaveVisitor(string id,string n, string c, decimal p, string e,string a, string city, string country) { drow = ds.Tables[0].NewRow(); drow[0] = id; drow[1] = n; drow[2] = c; drow[3] = p; drow[4] = e; drow[5] = a; drow[6] = city; drow[7] = country; ds.Tables[0].Rows.Add(drow); vda.InsertCommand = vcb.GetInsertCommand(); int res = vda.Update(ds.Tables[0]); // showing error if (res > 0) { System.Windows.Forms.MessageBox.Show("Visitor Details Added"); return true; } else return false; }

        J Offline
        J Offline
        J4amieC
        wrote on last edited by
        #3

        My guess is that the times you get the error its because "string or binary data would be truncated". Not sure why I think that though, it might have something to do with the error message. Of course, you might not understand what that error actually means, but google does[^]

        1 Reply Last reply
        0
        • A amaankhan

          Error "String or Binary data would be truncated. The Statement has been terminated" error on code >>>>>> public static bool SaveVisitor(string id,string n, string c, decimal p, string e,string a, string city, string country) { drow = ds.Tables[0].NewRow(); drow[0] = id; drow[1] = n; drow[2] = c; drow[3] = p; drow[4] = e; drow[5] = a; drow[6] = city; drow[7] = country; ds.Tables[0].Rows.Add(drow); vda.InsertCommand = vcb.GetInsertCommand(); int res = vda.Update(ds.Tables[0]); // showing error if (res > 0) { System.Windows.Forms.MessageBox.Show("Visitor Details Added"); return true; } else return false; }

          P Offline
          P Offline
          PIEBALDconsult
          wrote on last edited by
          #4

          DataAdapters are evil and should be avoided. If you want to insert some data, just insert it, it's not difficult and you'll be better off.

          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