Click here to Skip to main content
15,892,059 members
Please Sign up or sign in to vote.
1.20/5 (5 votes)
pls help me, i have table studentmaster(firstname,lastname,fathername,phone,address). i am inserting data into database 2 times the data will be inserted. forexample:

insert into studentmaster(firstname,lastname,fathername,phone,address) values('aaaa','bbbb,'cccc',1111,'delhi');
Posted
Comments
Sergey Alexandrovich Kryukov 16-Aug-12 15:18pm    
Do you have a question?
--SA
[no name] 16-Aug-12 15:31pm    
If you are telling us that if I were to go through the trouble of creating a table in my database like that and run that query once, it will actually insert the data 2 times? I do not think so.
ridoy 16-Aug-12 15:51pm    
Whether it is a question or a problem??

1 solution

When you insert a row to the database, a single row is inserted. The database doesn't duplicate the row automatically in any case. Possible reasons for the duplication include at least:

  • you execute the statement twice: Try to find if you for example have the call to ExecuteNonQuery mistakenly twice in your code
  • the insert statement is included twice in your SQL string. Using debugger, see if the insert statement is mistakenly put to the SQL string twice.
  • the method in your code is called twice. This should be easy to pinpoint. Put a breakpoint on the method and see when it's hit
  • you have a trigger that's causing the duplication. Investigate the triggers of the table using SSMS
  • a procedure does the insertion: see if you have a procedure that inserts the other row and if it's called from your application (or from a trigger)
 
Share this answer
 
Comments
[no name] 16-Aug-12 16:01pm    
Probably covers just about everything.
Wendelius 16-Aug-12 16:18pm    
Thanks :)
Espen Harlinn 16-Aug-12 16:25pm    
Well written reply :-D
Wendelius 16-Aug-12 16:57pm    
Thank you Espen :-D

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900