Databases Reference
In-Depth Information
Try It Out: Executing a Stored Procedure with No
Input Parameters
Here, you'll execute sp_Select_Employees_Details , which takes no input and returns only a
result set, a list of all employees sorted by name.
1. Create a new Console Application project named CallSp1. Rename the CallSp1
Solution to Chapter6.
2. Rename the Program.cs file to CallSp1.cs , and replace the generated code with the
code in Listing 6-1.
n Note You can easily rename the solution and project by selecting them, right-clicking, and selecting the
Rename option.
Listing 6-1. CallSp1.cs .
using System;
using System.Data;
using System.Data.SqlClient;
namespace Chapter6
{
class CallSp1
{
static void Main()
{
// create connection
SqlConnection conn = new SqlConnection
(@"server = .\sqlexpress;
integrated security = true;
database = northwind");
try
{
// open connection
conn.Open();
// create command
SqlCommand cmd = conn.CreateCommand();
Search WWH ::




Custom Search