Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<pre><code>using (SqlConnection conn = new SqlConnection("Server=(local);DataBase=Northwind;Integrated Security=SSPI")) { conn.Open(); // 1. create a command object identifying the stored procedure SqlCommand cmd = new SqlCommand("CustOrderHist", conn); // 2. set the command object so it knows to execute a stored procedure cmd.CommandType = CommandType.StoredProcedure; // 3. add parameter to command, which will be passed to the stored procedure cmd.Parameters.Add(new SqlParameter("@CustomerID", custId)); // execute the command using (SqlDataReader rdr = cmd.ExecuteReader()) { // iterate through results, printing each to console while (rdr.Read()) { Console.WriteLine("Product: {0,-35} Total: {1,2}",rdr["ProductName"],rdr["Total"]); } } } </code></pre> <p>Here are some interesting links you could read:</p> <ul> <li><a href="http://www.csharp-station.com/Tutorials/AdoDotNet/Lesson07.aspx" rel="noreferrer">http://www.csharp-station.com/Tutorials/AdoDotNet/Lesson07.aspx</a></li> <li><a href="http://www.c-sharpcorner.com/UploadFile/dclark/InsOutsinCS11302005072332AM/InsOutsinCS.aspx" rel="noreferrer">http://www.c-sharpcorner.com/UploadFile/dclark/InsOutsinCS11302005072332AM/InsOutsinCS.aspx</a></li> <li><a href="http://www.codeproject.com/KB/cs/simplecodeasp.aspx" rel="noreferrer">http://www.codeproject.com/KB/cs/simplecodeasp.aspx</a></li> <li><a href="http://msdn.microsoft.com/en-us/library/ms171921(VS.80).aspx" rel="noreferrer">http://msdn.microsoft.com/en-us/library/ms171921(VS.80).aspx</a></li> </ul>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload