| Author |
Topic |
|
sgupta3
Starting Member
7 Posts |
Posted - 2010-03-19 : 00:43:03
|
| Hello,I have a code in .Net which is inserting a row a sql table. The code is inserting the row once, but it is getting inserted into the table twice.How is it possible. Please help. |
|
|
senthil_nagore
Master Smack Fu Yak Hacker
1007 Posts |
Posted - 2010-03-19 : 00:59:18
|
| May be your .net method is called twice!Put a trace in the method and check it up!Senthil.C------------------------------------------------------[Microsoft][ODBC SQL Server Driver]Operation canceledhttp://senthilnagore.blogspot.com/ |
 |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2010-03-19 : 01:02:13
|
check your join condition KH[spoiler]Time is always against us[/spoiler] |
 |
|
|
haroon2k9
Constraint Violating Yak Guru
328 Posts |
Posted - 2010-03-19 : 01:03:02
|
| 1.After the submitted the page to server,when you hit the Refresh button,Row could be inserted again to your table unless or until if u are redireced to some other page.2.Check any trigger assciated with this table.if still have any issues,please show us your proc. |
 |
|
|
sgupta3
Starting Member
7 Posts |
Posted - 2010-03-19 : 01:38:02
|
| The code was working fine earlier. It is from 12th March that it is behaving like this. Nothing has changed in the code or in the table. Actually, the code to insert rows into the table is being called from a windows service which has been registered as a windows component. I have tried to uninstall the component and re-register it. But it has not solved my problem. |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2010-03-19 : 01:50:08
|
| Can you post the code you used?MadhivananFailing to plan is Planning to fail |
 |
|
|
sgupta3
Starting Member
7 Posts |
Posted - 2010-03-19 : 02:25:35
|
| I have this function which is called to build the query and then that query(strQuery) is executed.public static String InsertShipmentBatchDetailQuery(String strShipRequestBatchID, String strShipment_Order_GUID) { String strQuery = "insert into SAP_Ship_Request_Batch_Details(SAP_Ship_Request_Batch_Detail_ID,Ship_Request_Batch_ID,SHIPMENT_ORDER_GUID,Status,Error_Text,Number_Of_Retries) values(newid(), '" ; strQuery += strShipRequestBatchID ; strQuery += "','" + strShipment_Order_GUID + "', 'OPEN', '', 0)"; return strQuery; } |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2010-03-19 : 02:43:43
|
| Print the value of strQuery and post itMadhivananFailing to plan is Planning to fail |
 |
|
|
Sachin.Nand
2937 Posts |
Posted - 2010-03-19 : 02:45:30
|
| Can u put a breakpoint on return strQuery & see what value it is generating.PBUH |
 |
|
|
sgupta3
Starting Member
7 Posts |
Posted - 2010-03-19 : 02:54:41
|
| strQuery = insert into SAP_Ship_Request_Batch_Details(SAP_Ship_Request_Batch_Detail_ID,Ship_Request_Batch_ID,SHIPMENT_ORDER_GUID,Status,Error_Text,Number_Of_Retries) values('AD01F51F-D876-48EA-B815-791EA804FFEF','9E2C48AC-28EF-4B28-AB06-4C2CB06BA1CA','55A4FCBF-1867-48BF-8D44-FB388C32FA3B','OPEN','', 0) |
 |
|
|
haroon2k9
Constraint Violating Yak Guru
328 Posts |
Posted - 2010-03-19 : 02:57:48
|
quote: Originally posted by sgupta3 strQuery = insert into SAP_Ship_Request_Batch_Details(SAP_Ship_Request_Batch_Detail_ID,Ship_Request_Batch_ID,SHIPMENT_ORDER_GUID,Status,Error_Text,Number_Of_Retries) values('AD01F51F-D876-48EA-B815-791EA804FFEF','9E2C48AC-28EF-4B28-AB06-4C2CB06BA1CA','55A4FCBF-1867-48BF-8D44-FB388C32FA3B','OPEN','', 0)
just exec this on backend and see,does this value inserting one time or what?insert into SAP_Ship_Request_Batch_Details(SAP_Ship_Request_Batch_Detail_ID,Ship_Request_Batch_ID,SHIPMENT_ORDER_GUID,Status,Error_Text,Number_Of_Retries) values('AD01F51F-D876-48EA-B815-791EA804FFEF','9E2C48AC-28EF-4B28-AB06-4C2CB06BA1CA','55A4FCBF-1867-48BF-8D44-FB388C32FA3B','OPEN','', 0) |
 |
|
|
haroon2k9
Constraint Violating Yak Guru
328 Posts |
Posted - 2010-03-19 : 03:01:31
|
quote: Originally posted by sgupta3 strQuery = insert into SAP_Ship_Request_Batch_Details(SAP_Ship_Request_Batch_Detail_ID,Ship_Request_Batch_ID,SHIPMENT_ORDER_GUID,Status,Error_Text,Number_Of_Retries) values('AD01F51F-D876-48EA-B815-791EA804FFEF','9E2C48AC-28EF-4B28-AB06-4C2CB06BA1CA','55A4FCBF-1867-48BF-8D44-FB388C32FA3B','OPEN','', 0)
1.i can see,only 5 cloumns but you are passing 6 parameter..check this..2.as i said earlier,any trigger asscaited with this tabl. |
 |
|
|
sgupta3
Starting Member
7 Posts |
Posted - 2010-03-19 : 03:09:56
|
| It is inserting only once |
 |
|
|
sgupta3
Starting Member
7 Posts |
Posted - 2010-03-19 : 03:17:09
|
| Hi haroon2k9, there are 6 columns. And there is one trigger with this table...but that is on update only. |
 |
|
|
haroon2k9
Constraint Violating Yak Guru
328 Posts |
Posted - 2010-03-19 : 03:29:06
|
quote: Originally posted by sgupta3 Hi haroon2k9, there are 6 columns. And there is one trigger with this table...but that is on update only.
please show us that trigger query |
 |
|
|
Kristen
Test
22859 Posts |
Posted - 2010-03-19 : 04:10:43
|
| [code]BEGIN TRANSACTIONSELECT [Before]=COUNT(*) FROM SAP_Ship_Request_Batch_Details WHERE SAP_Ship_Request_Batch_Detail_ID = 'AD01F51F-D876-48EA-B815-791EA804FFEF'insert into SAP_Ship_Request_Batch_Details( SAP_Ship_Request_Batch_Detail_ID,Ship_Request_Batch_ID,SHIPMENT_ORDER_GUID,Status,Error_Text,Number_Of_Retries) values('AD01F51F-D876-48EA-B815-791EA804FFEF','9E2C48AC-28EF-4B28-AB06-4C2CB06BA1CA','55A4FCBF-1867-48BF-8D44-FB388C32FA3B','OPEN','', 0)SELECT [After]=COUNT(*) FROM SAP_Ship_Request_Batch_Details WHERE SAP_Ship_Request_Batch_Detail_ID = 'AD01F51F-D876-48EA-B815-791EA804FFEF'ROLLBACK[/code]This will show number of rows with that ID before / after an insert. If it inserts only one row the problem is (most probably) not in SQL Server-side, so is not a trigger or somesuch. If it inserts 2 rows then the problem is DEFINITELY within SQL server-side |
 |
|
|
sgupta3
Starting Member
7 Posts |
Posted - 2010-03-19 : 04:22:17
|
| Thanks Kristen.I am also assuming that the problem is not with SQL as it is inserting one row only. I am looking on other facets also. May be the problem is with the components registeration.Thank you all for your help. |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2010-03-19 : 04:51:47
|
| Have a look at the profiler and see if you get a clueMadhivananFailing to plan is Planning to fail |
 |
|
|
Kristen
Test
22859 Posts |
Posted - 2010-03-19 : 05:30:22
|
quote: Originally posted by madhivanan Have a look at the profiler and see if you get a clue
Good idea! |
 |
|
|
|