ReturnValue));
}
Unlike the first example, this example is returning a singleton value, so no table definition is required.
You do, however, need to add the code to call the stored procedure, so in the click event for button2, add
the following code:
private void button2_Click(object sender, EventArgs e)
{
AdventureWorks db = new AdventureWorks("Integrated Security=sspi");
int bigOrder = 0;
db.MaxOrder(275, ref bigOrder);
listBox1.Items.Add(bigOrder);
}
This example defines an initial value for the returned parameter, and passes that along with the ID of the
salesperson to the stored procedure.
Run the project again and click button2. This time the list box will be populated with a value of 198628
(if you used ID 275). Pretty slick, isn??™t it?
Mapped Stored Procedures forMultiple Results
The following example shows how to handle circumstances where you might not know the exact results
coming back. It creates a stored procedure that accepts a single parameter of data type int. Based on the
value of the parameter, one of two statements will be executed.
Pages:
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383