0

i have form view i wrote this code in event sqlds_inserted

text1.text=e.Command.ExecuteScalar().ToString(); 

to have the id for the last inserted record it works but every time i add record it inserts tow records with the same data when i delete this code it works fine

Andrey
  • 59,039
  • 12
  • 119
  • 163
TARIK
  • 1
  • my sql statment INSERT INTO MainData(Emp_Identity_Number, Emp_IdentityID) VALUES (@Emp_Identity_Number, @Emp_IdentityID); SELECT SCOPE_IDENTITY() – TARIK May 06 '10 at 15:28
  • are you sure that you statement is executed only once? – volody May 06 '10 at 16:20

1 Answers1

2

The formview is inserting a record via the default sqldatasource (or objectdatasource, etc...) and then you are calling another insert via the ExecuteScalar method (e in your code represents the datasource you are using).

MessedUp
  • 21
  • 2