Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
AskSQLTeam
Ask SQLTeam Question
0 Posts |
Posted - 2003-08-05 : 07:15:15
|
| Navin writes "HiAm inserting data into SQL server 2000 from one asp page. When i submit form i find two records of same information with two different slno's. Slno is not duplicated, but all other field values are same. How to stop this happening?Thanksnaveen" |
|
|
mohdowais
Sheikh of Yak Knowledge
1456 Posts |
Posted - 2003-08-05 : 09:53:19
|
Now its my turn to say ITS ONE OF THOSE MIRACLE THINGS!! There are no miracles in SQL Server.Navin, we need to see some code here. I guess you SlNo is an IDENTITY column, hence it wont repeat. A lot of things can cause duplicate inserts, least of which is the user hitting the "Submit" button twice. I've seen javascript code that simulates the same functionality . Check your page code again, it's gotta be somewhere right there.Owais |
 |
|
|
X002548
Not Just a Number
15586 Posts |
Posted - 2003-08-05 : 12:08:10
|
quote: Originally posted by mohdowais Now its my turn to say ITS ONE OF THOSE MIRACLE THINGS!! 
I hate when that happens....LOL$1,000US slno is an (you guessed it) IDENTITY Column...Is there a better to uniquely identify a row? That way you can put a constraint on, and handle the dup error...Brett8-)SELECT POST=NewId() |
 |
|
|
vganesh76
Yak Posting Veteran
64 Posts |
Posted - 2003-08-07 : 01:47:59
|
| Probably u would have used a function which would have the command like document.forms(0).submit()Also u would have a button of type submit.I think case the form is submitted twice.Either use submit button or use type=button with a javascript function which for submitting the pagefor example ur code might be<input type="submit" value="Submit" onclick="fnsubmit()"><script language="javascript">function fnsubmit(){// which does some validation of controls document.forms(0).submit()}</script>In the above scenario the form is submitted twicetry one of these1. <input type="button" value="Submit" onclick="fnsubmit()"><script language="javascript">function fnsubmit(){// which does some validation of controls document.forms(0).submit()}</script>(or)2. <input type="Submit" value="Submit" onclick="fnsubmit()"><script language="javascript">function fnsubmit(){// which does some validation of controls //document.forms(0).submit() -- Donot include this line in the function}</script>V.GaneshNetAssetManagement.comvganesh76@rediffmail.comEnjoy working |
 |
|
|
|
|
|