I have create a stored procedure with name getCusnmae1
set ANSI_NULLS ON
set QUOTED_IDENTIFIER ON
go
ALTER PROCEDURE [dbo].[getCusnmae1]
AS
BEGIN
SELECT ALL * FROM dbo.Customers;
SELECT ALL * FROM dbo.Order1;
END
now what i have done so far that create a property class Customer and want to display data on the grid
I wrote the code for this is:
conn1.ConnectionString = " server=.\\ms2k5;database=Inventory;Trusted_Connection=true";
conn1.Open();
SqlCommand testCMD = new SqlCommand ("getCusnmae1", conn1);
testCMD.CommandType = CommandType.StoredProcedure;
SqlDataReader myReader = testCMD.ExecuteReader();
List<Customer> list = new List<Customer>();
while (myReader.Read())
{
Customer md = new Customer();
md.CustName = myReader.;
md.custname = myReader.GetValue(1).ToString();
md.contact = myReader.GetValue(2).ToString();
list.Add(md);
}
by which I get column value only from the Customers Table
what i Have to do to get data from child table Order1
When I write
md.contact = myReader.GetValue(3).ToString();
to acess order table it does not work..
please help
thanks
Use SqlDataReader.NextResult() method to handle multiple Results.