Hi,
I'm a student and have the following working example on an
aspx page
(.NET 2.00) (C# code Page_Load):
try
{
if (User.Identity.IsAuthenticated == true)
{
try
{
string theUser;
theUser = User.Identity.Name;
this.lblUsername.Text = theUser;
SqlConnection conn = new
SqlConnection(GetConnectionString());
SqlCommand cmd = new
SqlCommand("dbo.CustomersOrderHistory", conn);
cmd.CommandType =
CommandType.StoredProcedure;
cmd.Parameters.Add(" Firstname",
SqlDbType.VarChar).Value = theUser;
conn.Open();
SqlDataReader rd = cmd.ExecuteReader();
while (rd.Read())
{
gvCustOrdHist.DataBind();
}
conn.Close();
}
catch (SqlException sqlex)
{
lblError.Text = "An database error
occurred with
text: " + "n" + "n" +
sqlex.Message;
}
}
}
Now the stored procedure is(SQL Server 2005):
CREATE PROCEDURE dbo.CustomersOrderHistory
( Firstname varchar(7))
AS
SELECT dbo.Customers.Firstname, dbo.Orders.Orderdate,
dbo.Orderdetails.Orderamount, dbo.Orderdetails.Orderprice,
dbo.Orderdetails.Orderdiscount,
dbo.Items.Itemname,dbo.Orderdetails.Orderamount
* dbo.Orderdetails.Orderprice AS Ordersum
FROM dbo.Orderdetails INNER JOIN
dbo.Items ON dbo.Orderdetails.ItemID
=
dbo.Items.ItemID INNER JOIN
dbo.Orders ON dbo.Orderdetails.OrderID
=
dbo.Orders.OrderID INNER JOIN
dbo.Customers ON dbo.Orders.Customer
=
dbo.Customers.CustomerID
WHERE dbo.Customers.Firstname LIKE
Firstname
ORDER BY dbo.Orders.Orderdate
/* SET NOCOUNT ON */
RETURN  ERROR
However, no data is returned and I wonder why. Can you see
why?
The connection string:
private static string GetConnectionString()
{
return
ConfigurationManager.ConnectionStrings["csCustomersOrde
rHistory"].ConnectionString;
}
It works ok if I use a dataset, but I want to use
DataReader.
Any tip?
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the
Google Groups "C-Sharp (C#)" group.
To post to this group, send email to C_Sharp googlegroups.com
To unsubscribe from this group, send email to
C_Sharp-unsubscribe googlegroups.com
For more options, visit this group at http://g
roups.google.com/group/C_Sharp?hl=en
-~----------~----~----~----~------~----~------~--~---
|