1,105,312 Community Members

VB.NET get Return Values from SQL UPDATE

Member Avatar
JohnKelly
Light Poster
38 posts since Sep 2006
Reputation Points: 0 [?]
Q&As Helped to Solve: 1 [?]
Skill Endorsements: 0 [?]
 
0
 

Dear All

I am using Vb.net to update a database running on SQL Server.

I am using the following to increase the value of the NextPlan in the SystemControl table in a SQL database.

Command.CommandText = "UPDATE SystemControl SET NextPlan = NextPlan + 1"
Command.ExecuteNonQuery()

Once the Command is executed and I look in the actual database I can see the value has been incremented. How can I get the Command to return the new value of NextPlan so I don't need to then do a table read to get the new value.

Thanks

Member Avatar
kRod
Junior Poster
139 posts since May 2012
Reputation Points: 49 [?]
Q&As Helped to Solve: 35 [?]
Skill Endorsements: 6 [?]
 
0
 

Try the following

Dim id as Integer = Command.ExecuteScalar()
Question Answered as of 7 Months Ago by kRod
Member Avatar
JohnKelly
Light Poster
38 posts since Sep 2006
Reputation Points: 0 [?]
Q&As Helped to Solve: 1 [?]
Skill Endorsements: 0 [?]
 
0
 

Thank you

You
This question has already been solved: Start a new discussion instead
Post:
Start New Discussion
View similar articles that have also been tagged: