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. database

database

Scheduled Pinned Locked Moved ASP.NET
databasetutorialquestion
5 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.
  • J Offline
    J Offline
    jds1207
    wrote on last edited by
    #1

    I am trying to read a sql database so the same rows will not be inserted. I already got the connection I just need to know how to not insert the same row twice. I am using the VB language. Any ideas?

    N K M 3 Replies Last reply
    0
    • J jds1207

      I am trying to read a sql database so the same rows will not be inserted. I already got the connection I just need to know how to not insert the same row twice. I am using the VB language. Any ideas?

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

      jds1207 wrote:

      so the same rows will not be inserted

      so u don`t wan`t to insert anything...

      jds1207 wrote:

      I just need to know how to not insert the same row twice

      But now you are saying u need to insert it twice.... Pls be a bit more clear every time u post a question, otherwise u ll keep howling like a donkey...

      J 1 Reply Last reply
      0
      • N NetBot

        jds1207 wrote:

        so the same rows will not be inserted

        so u don`t wan`t to insert anything...

        jds1207 wrote:

        I just need to know how to not insert the same row twice

        But now you are saying u need to insert it twice.... Pls be a bit more clear every time u post a question, otherwise u ll keep howling like a donkey...

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

        This is how I am trying to get it. For example, If I insert a row into the database that have a department name HR and a username user.name and I try to insert another row that has the same department and username, the new row can't be inserted because the department and username already exists.

        1 Reply Last reply
        0
        • J jds1207

          I am trying to read a sql database so the same rows will not be inserted. I already got the connection I just need to know how to not insert the same row twice. I am using the VB language. Any ideas?

          K Offline
          K Offline
          Kschuler
          wrote on last edited by
          #4

          You could first select the record you are trying to insert. If you get something back, then you know it already exists. I would also recommend that you research using a DataAdapter object which, if setup correctly, can help a lot with inserting, updating, deleting, etc. You could start your research with some of these articles.[^] Hope this helps.

          1 Reply Last reply
          0
          • J jds1207

            I am trying to read a sql database so the same rows will not be inserted. I already got the connection I just need to know how to not insert the same row twice. I am using the VB language. Any ideas?

            M Offline
            M Offline
            Mark Churchill
            wrote on last edited by
            #5

            Read up on unique constraints. Generally your database shouldn't let you insert "bad" data, so you enforce this with constraints. Then your UI probably should deal with the situation nicely, either by checking first, or handling the exception that gets thrown when you try to insert the second row.

            Mark Churchill Director Dunn & Churchill Free Download:
            Diamond Binding: The simple, powerful, reliable, and effective data layer toolkit for Visual Studio.

            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