I insert a value / new row and I need the ID, but I get an error…
SQL code:
INSERT INTO [StoneTable] ([StoneName]) VALUES (@StoneName)
SELECT SCOPE_IDENTITY()
Using this code to insert row and getting the ID:
stoneTableTableAdapter = new StoneTableTabelleTableAdapter();
int id = Convert.ToInt32(stoneTableTableAdapter.InsertStoneNameAndReturnId("anything"));
//And on this 2nd Line I got an error
Error message:
There was an error parsing the query. [ Token line number = 2,Token line offset = 1,Token in error = SELECT ]
What’s the problem? In my other project I use the same syntax, with no problems. Tried with @@IDENTITY, as well not working….
See the answer to this question for a suggestion on how to make your example work: