我创建了一个名为 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
现在我到目前为止所做的是创建一个属性类 Customer 并希望在网格上显示数据
我为此编写的代码是:
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);
}
通过它我只从客户表中获取列值我必须做什么才能从子表 Order1 中获取数据
当我写
md.contact = myReader.GetValue(3).ToString();
访问订单表它不起作用..
请帮忙谢谢