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