| |

VerySource

 Forgot password?
 Register
Search
View: 685|Reply: 4

After inserting data into the SqlServer database using TableAdapter, how to obtain the ID of the auto-increment type?

[Copy link]

1

Threads

3

Posts

3.00

Credits

Newbie

Rank: 1

Credits
3.00

 China

Post time: 2020-1-23 10:00:01
| Show all posts |Read mode
After inserting data into the SqlServer database using TableAdapter, how to obtain the ID of the auto-increment type?
Can not use stored procedures, I do not know which master can help solve.
The key is whether the InsertCommand in the TableAdapter can return @@ Indentity, or create a new OUTPUT parameter and return @@ Indentity.
Reply

Use magic Report

0

Threads

46

Posts

23.00

Credits

Newbie

Rank: 1

Credits
23.00

 China

Post time: 2020-2-8 07:15:01
| Show all posts
SELECT @@ Indentity returns.
Reply

Use magic Report

1

Threads

3

Posts

3.00

Credits

Newbie

Rank: 1

Credits
3.00

 China

 Author| Post time: 2020-2-18 10:15:02
| Show all posts
INSERT INTO TM_Class
      (D_ClassName, D_RootID, D_Level, D_Order, D_Summary)
VALUES (@ D_ClassName, @ D_RootID, @ D_Level, @ D_Order, @ D_Summary)
GO
SELECT SELECT @@ Indentity FROM TM_Class

Is this written in the InsertCommand of the TableAdapter? But TableAdapter's InsertCommand does not support running two SQL statements at the same time! !! !!
Reply

Use magic Report

1

Threads

3

Posts

3.00

Credits

Newbie

Rank: 1

Credits
3.00

 China

 Author| Post time: 2020-2-18 11:30:01
| Show all posts
This is a question about strongly typed DataSets.
Reply

Use magic Report

0

Threads

5

Posts

6.00

Credits

Newbie

Rank: 1

Credits
6.00

 China

Post time: 2020-3-4 17:00:01
| Show all posts
You can use transactions, insert to start, and select to end.
Reply

Use magic Report

You have to log in before you can reply Login | Register

Points Rules

Contact us|Archive|Mobile|CopyRight © 2008-2023|verysource.com ( 京ICP备17048824号-1 )

Quick Reply To Top Return to the list