Tutorials ADO.NET Core Tutorial
Output Parameters — Complete Guide
Output Parameters — Complete Guide: free step-by-step lesson with examples, common mistakes, and interview tips — part of ADO.NET Core Tutorial on Toolliyo Academy.
On this page
ADO.NET Core Tutorial · Lesson 25 of 100
Output Parameters
Foundations ✓ → SQL & safety → Production → Projects
SQL & safety · 2 — Procs, tx, performance · ~6 min · Module 3: Stored Procedures
What is this?
Output parameters return values from procedures via ParameterDirection.Output after Execute*.
Why should you care?
ShopNest create-order procs often return NewId or row counts as outputs.
See it live — copy this example
Use a .NET console or API project with SQL Server LocalDB. Run dotnet run after pasting.
var p = cmd.Parameters.Add("@NewId", SqlDbType.Int);
p.Direction = ParameterDirection.Output;
await cmd.ExecuteNonQueryAsync(ct);
Console.WriteLine((int)p.Value!);
What happened?
- Set Direction.Output before execute.
- Read .Value after.
- Use ReturnValue for integer status codes separately.
Practice next
- Proc sets @NewId = SCOPE_IDENTITY().
- Read output in C#.
- Combine with result set carefully.
- Add @Rows INT OUTPUT.
- Return both id and rows.
Remember
Direction.Output. Read after execute. Distinct from return codes.
ShopNest new id output
usp_Orders_Create returns @NewId.
Outcome: API responds with created id.
Interview prep for this lesson
Practice these questions aloud after reading—each links to a full structured answer.
Sign in to ask a question or upvote helpful answers.
No questions yet — be the first to ask!