I have a field in table that is auto increment. There increment and seed is (1,1) .So My first row enter in database table then this field value is 1. After that i am inserting second row but from the catch block my transaction is rollback(i am using commit in try block after insert statement.). so my second row did not insert. now i am insert again a row that time it inserted and my auto increment field value is 3 and total rows are 2. that is my problem "If row does not insert in to database table then why increment auto increment field of database table ".
If i am say something wrong pls ignore it.
Loading


Dorababu MekaRank #457 · 5.5K reputationPosted Jun 1, 2011, 2:02 AM EDT
Sandeep ShekhawatRank #2,439 · 577 reputationPosted Jun 1, 2011, 2:10 AM EDT
My Store procedure is (parameter a lot of so ignore parameter).
Sandeep ShekhawatRank #2,439 · 577 reputationPosted Jun 1, 2011, 7:00 AM EDT
Suthish NairRank #92 · 22.8K reputationPosted Jun 1, 2011, 11:04 AM EDT
Sandeep ShekhawatRank #2,439 · 577 reputationPosted Jun 1, 2011, 2:53 PM EDT
Hi Suthish Sir
select @username=user_name,@password=passowrd from dbo.LoginInfo(@mail)
By this query when user name already exists then second inserting is failed and whole transaction rollback.
ashrafuddin22 reputationPosted Jun 1, 2011, 11:48 PM EDT
I think you can use Transaction Scope in DotNet.It will help you in checking that the record is not inserted unless all the transaction is complete.
Take a look at following link
http://www.codeproject.com/KB/dotnet/TransactionScope20.aspx
With Regards,
Ashrafuddin.T