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. inserting wrong number of records

inserting wrong number of records

Scheduled Pinned Locked Moved C#
databasequestioncsssql-serversysadmin
4 Posts 2 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.
  • D Offline
    D Offline
    DownBySpj
    wrote on last edited by
    #1

    Hi, My job is to read a text file and insert all the records from that text file to a database table. I have partly done that. There is an identity field in the table named record_id. I am buliding the sql insert insertment taking values from text file and inserting records. Everything is fine as long as the number of records are less, say, 50 or 100 or 150. If the number of records goes above that all the records are not inserted. As against 766 records only 606 records are inserted. Also the autoincrement field should increment uniformly. But it is not happening so. What is the problem ? Is there a sql server problem or some logic problem. Any suggestion is welcome :confused:

    G 1 Reply Last reply
    0
    • D DownBySpj

      Hi, My job is to read a text file and insert all the records from that text file to a database table. I have partly done that. There is an identity field in the table named record_id. I am buliding the sql insert insertment taking values from text file and inserting records. Everything is fine as long as the number of records are less, say, 50 or 100 or 150. If the number of records goes above that all the records are not inserted. As against 766 records only 606 records are inserted. Also the autoincrement field should increment uniformly. But it is not happening so. What is the problem ? Is there a sql server problem or some logic problem. Any suggestion is welcome :confused:

      G Offline
      G Offline
      Guffa
      wrote on last edited by
      #2

      How are you checking what records has been added?

      DownBySpj wrote:

      As against 766 records only 606 records are inserted.

      Are you catching exceptions and ignoring them, or something? I have yet to see an insert statement that fails without sending an error message.

      DownBySpj wrote:

      Also the autoincrement field should increment uniformly. But it is not happening so.

      What happens, then?

      --- b { font-weight: normal; }

      D 1 Reply Last reply
      0
      • G Guffa

        How are you checking what records has been added?

        DownBySpj wrote:

        As against 766 records only 606 records are inserted.

        Are you catching exceptions and ignoring them, or something? I have yet to see an insert statement that fails without sending an error message.

        DownBySpj wrote:

        Also the autoincrement field should increment uniformly. But it is not happening so.

        What happens, then?

        --- b { font-weight: normal; }

        D Offline
        D Offline
        DownBySpj
        wrote on last edited by
        #3

        hi, In the inserting module i am incrementing a counter if there is a sucessfull insert. This lets me know about the number of records that are processed by the code. And in the database table, i use just " select * " statement to know exactly how many records are inserted. Before the insertion table is empty. So the number of records returned is the number of records inserted by the code. But there is a problem somewhere, that's why it is showing me wrong no. I am first reading the whole file in a string array. This way it becomes cler about, how many records are there, and then i inserts the records one by one. But it is happening so. If an exception regarding primary key, or foreign key or any other, i am incrementing a counter for errors. But the probelm is it is not showing any error. Any help :doh:

        G 1 Reply Last reply
        0
        • D DownBySpj

          hi, In the inserting module i am incrementing a counter if there is a sucessfull insert. This lets me know about the number of records that are processed by the code. And in the database table, i use just " select * " statement to know exactly how many records are inserted. Before the insertion table is empty. So the number of records returned is the number of records inserted by the code. But there is a problem somewhere, that's why it is showing me wrong no. I am first reading the whole file in a string array. This way it becomes cler about, how many records are there, and then i inserts the records one by one. But it is happening so. If an exception regarding primary key, or foreign key or any other, i am incrementing a counter for errors. But the probelm is it is not showing any error. Any help :doh:

          G Offline
          G Offline
          Guffa
          wrote on last edited by
          #4

          DownBySpj wrote:

          And in the database table, i use just " select * " statement to know exactly how many records are inserted.

          Yes, but what are you using to run the query? If you for example run it from the code right after inserting the records, but are using a different connection than the one used to insert while the first connection is still open, some records might not show up yet although they exist. What does the insert query look like? Are you sure that it always results in inserting a record? If you for example select data from another table in the insert, are you sure that you always get a record from that table?

          --- b { font-weight: normal; }

          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