资 源 简 介
C# 查询订购产品ID为51的客户信息,需要连接数据库来测试,相关代码分享如下:
//查询订购产品ID为51的客户信息
SqlConnection MyConnection = new SqlConnection(@"Data Source =luobin-PCSQLEXPRESS;Initial Catalog=Northwind;Integrated Security=True");
MyConnection.Open();
DataSet MyDataSet = new DataSet("CustomerOrdersDetails");
SqlDataAdapter MyCustomerAdapter = new SqlDataAdapter("SELECT * FROM Customers", MyConnection);
MyCustomerAdapter.Fill(MyDataSet, "Customers");
DataTable MyTable = new DataTable();
MyCustomerAdapter.Fill(MyTable);
SqlDataAdapter MyOrderAdapter = new SqlDataAdapter("SELECT * FROM Orders", MyConnection);
MyOrderAdapter.Fill(MyDataSet, "Orders");
SqlDataAdapter MyDetailAdapter = new SqlDataAdapter("SELECT * FROM [Order Details]", MyConnection);
MyDetailAdapter.Fill(MyDataSet, "OrderDetails");
MyConnection.Close();
MyDataSet.Relations.Add("CustOrders",MyDataSet.Tables["Customers"].Columns["CustomerID"],MyDataSet.Tables["Orders"].Columns["CustomerID"]).Nested = true;
MyDataSet.Relations.Add(