Saturday, March 02, 2013

retrieving Database Identity Colum Values (e.g. Autoincrement) from SqlServer


Use the "OUTPUT inserted.*" Clause on the Insert Command:
INSERT INTO [dbo].[Spiele] ([Name], [C], [L]) OUTPUT inserted.*  VALUES (@Name, @C, @L)
check by Debugging the taSpiele.Adapter.InsertCommand.CommandText before calling taSpiel.Update to ensure the OUTPUT Clause is there. You can add the OUTPUT inserted.* clause in the Dataset Designer on the Table Adpater Properties Page InsertCommand


Nutze die  "OUTPUT inserted.*" Klausel für den Insert Command:
INSERT INTO [dbo].[Spiele] ([Name], [C], [L]) OUTPUT inserted.*  VALUES (@Name, @C, @L)
sicherheitshalber mittels Debugger überprüfen ob taSpiele.Adapter.InsertCommand.CommandText auch tatsächlcih die OUPUT Klausel enthält  vor dem Aufruf  taSpiel.Update.
Die  OUTPUT inserted.* Klausel kann z.b. mit dem  Dataset Designer bei den  Table Adpater Properties Page InsertCommand hinzugefügt werden

No comments: