J
JMM B
In the code bellow, I tried:
this.sqlCommand1.ExecuteScalar();
this.sqlCommand1.ExecuteReader();
this.sqlCommand1.ExecuteNonQuery();
All work! But, What would be the best to choose for the mensioned Stored
Procedure?
thanks.
this.sqlCommand1.Parameters["@CustomerID"].Value = this.textBox1.Text;
this.sqlConnection1.Open();
this.sqlCommand1.ExecuteScalar();
this.label1.Text =
this.sqlCommand1.Parameters["@RETURN_VALUE"].Value.ToString();
this.sqlConnection1.Close();
this.label2.Text =
this.sqlCommand1.Parameters["@CompanyName"].Value.ToString();
ALTER PROCEDURE dbo.CountOrders
(
@CustomerID nchar(5),
@CompanyName nvarchar(40) OUTPUT
)
AS
SET NOCOUNT ON
DECLARE @OrdersCount int
SELECT @CompanyName = Customers.CompanyName, @OrdersCount =
COUNT(Orders.OrderID)
FROM Customers INNER JOIN Orders
ON Customers.CustomerID = Orders.CustomerID
WHERE (Customers.CustomerID = @CustomerID)
GROUP BY Customers.CompanyName
RETURN @OrdersCount
this.sqlCommand1.ExecuteScalar();
this.sqlCommand1.ExecuteReader();
this.sqlCommand1.ExecuteNonQuery();
All work! But, What would be the best to choose for the mensioned Stored
Procedure?
thanks.
this.sqlCommand1.Parameters["@CustomerID"].Value = this.textBox1.Text;
this.sqlConnection1.Open();
this.sqlCommand1.ExecuteScalar();
this.label1.Text =
this.sqlCommand1.Parameters["@RETURN_VALUE"].Value.ToString();
this.sqlConnection1.Close();
this.label2.Text =
this.sqlCommand1.Parameters["@CompanyName"].Value.ToString();
ALTER PROCEDURE dbo.CountOrders
(
@CustomerID nchar(5),
@CompanyName nvarchar(40) OUTPUT
)
AS
SET NOCOUNT ON
DECLARE @OrdersCount int
SELECT @CompanyName = Customers.CompanyName, @OrdersCount =
COUNT(Orders.OrderID)
FROM Customers INNER JOIN Orders
ON Customers.CustomerID = Orders.CustomerID
WHERE (Customers.CustomerID = @CustomerID)
GROUP BY Customers.CompanyName
RETURN @OrdersCount