protected void Page_Load(object sender, EventArgs e) { DataSet1.CategoryDataTable Category = new DataSet1.CategoryDataTable(); CategoryTableAdapter catAdap = new CategoryTableAdapter(); DataSet1.ProductsDataTable Products = new DataSet1.ProductsDataTable(); ProductsTableAdapter prodAdap = new ProductsTableAdapter(); catAdap.Fill(Category); prodAdap.Fill(Products); var result = from item in Products select item; DataTable queriedProducts = result.CopyToDataTable <DataSet1.ProductsRow>(); queriedProducts.TableName = "queriedProducts"; DataSet1 ds = new DataSet1(); ds.Tables.Add(queriedProducts); //DataView view = result.AsDataView<DataSet1.ProductsRow>(); //view.RowFilter = "CategoryID = 65985"; GridView1.DataSource = ds.Tables["queriedProducts"]; GridView1.DataBind(); }
public void DataViewDemo() { DataSet1.CategoryDataTable Category = new DataSet1.CategoryDataTable(); CategoryTableAdapter catAdap = new CategoryTableAdapter(); catAdap.Fill(Category); DataSet1.ProductsDataTable Products = new DataSet1.ProductsDataTable(); ProductsTableAdapter prodAdap = new ProductsTableAdapter(); prodAdap.Fill(Products); var result = from item in Products select item; DataView view = result.AsDataView(); view.Sort = "ProductName desc"; view.RowFilter = "CategoryID = 65985"; GridView7.DataSource = view; GridView7.DataBind(); DataSet1.ProductsRow row = null; List <DataSet1.ProductsRow> myList = new List <DataSet1.ProductsRow>(); foreach (DataRowView item in view) { row = (DataSet1.ProductsRow)item.Row; myList.Add(row); } GridView8.DataSource = myList; GridView8.DataBind(); }
protected override void FillDataSources(XtraReport report, string reportName, bool isDesignActive) { var dataSet = (Northwind)report.GetDataSourceByName("Northwind"); using (var adapter = new ProductsTableAdapter()) adapter.Fill(dataSet.Products); }
//一个填充Northwind数据库中产品和供应商到DataSet中去的函数 protected void FillDataSet() { ProductsTableAdapter productadapter = new ProductsTableAdapter(); productadapter.Fill(ds.Products); SuppliersTableAdapter supplieradapter = new SuppliersTableAdapter(); supplieradapter.Fill(ds.Suppliers); }
static void Main(string[] args) { using (NorthwindDataSet ds = new NorthwindDataSet()) using (CategoriesTableAdapter tac = new CategoriesTableAdapter()) using (ProductsTableAdapter tap = new ProductsTableAdapter()) { tac.Fill(ds.Categories); tap.Fill(ds.Products); foreach (var item in ds.Categories) { Console.WriteLine("{0} {1} {2}", item.ItemArray); NorthwindDataSet.ProductsRow[] childs = item.GetProductsRows(); foreach (var item2 in childs) { Console.WriteLine("\t{0} {1} {2} {3} ", item2.CategoryID, item2.ProductID, item2.ProductName, item2.UnitPrice); } } } }
private void Form1_Load(object sender, EventArgs e) { pta.Fill(sado.Products); dgProduits.DataSource = sado.Products; // TODO: cette ligne de code charge les données dans la table 'sourceADO.Products'. Vous pouvez la déplacer ou la supprimer selon les besoins. //this.productsTableAdapter.Fill(this.sourceADO.Products); }
//一个填充Northwind数据库中产品和供应商到DataSet中去的函数 protected void FillDataSet() { ProductsTableAdapter productadapter = new ProductsTableAdapter(); productadapter.Fill(ds.Products); SuppliersTableAdapter supplieradapter = new SuppliersTableAdapter(); supplieradapter.Fill(ds.Suppliers); }
// Populate your datasources for an editing session using the following method. protected override void FillDataSources(XtraReport report, string reportName, bool isDesignActive) { DataSet1 dataSet = (DataSet1)report.GetDataSourceByName("XtraReport1Data"); using (var categoriesTableAdapter = new CategoriesTableAdapter()) using (var productsTableAdapter = new ProductsTableAdapter()) { categoriesTableAdapter.Fill(dataSet.Categories); productsTableAdapter.Fill(dataSet.Products); } }
public static Northwind CreateNorthwindData() { var northwind = new Northwind(); using (var categoriesAdapter = new CategoriesTableAdapter()) using (var productsAdapter = new ProductsTableAdapter()) { categoriesAdapter.Fill(northwind.Categories); productsAdapter.Fill(northwind.Products); } return(northwind); }
private static object GetDataSource() { NWindDataSet dataSource = new NWindDataSet(); var connection = new SqlConnection(); connection.ConnectionString = Properties.Settings.Default.NWindConnectionString; ProductsTableAdapter products = new ProductsTableAdapter(); products.Connection = connection; products.Fill(dataSource.Products); return(dataSource.Products); }
static SalesReceipt() { ProductsTableAdapter productsTableAdapter = new ProductsTableAdapter(); servicesTableAdapter servicesTableAdapter = new servicesTableAdapter(); receiptModifyTableAdapter receiptModifyTableAdapter = new receiptModifyTableAdapter(); order_lineTableAdapter order_LineTableAdapter = new order_lineTableAdapter(); try { receiptModifyTableAdapter.Fill(dsSales.receiptModify); productsTableAdapter.Fill(dsSales.Products); servicesTableAdapter.Fill(dsSales.services); order_LineTableAdapter.Fill(dsSales.order_line); } catch (Exception) { } }
protected nwndDataSet GetData() { if ((nwndDataSet)Session["dataset"] == null) { nwndDataSet ds = new nwndDataSet(); CategoriesTableAdapter cta = new CategoriesTableAdapter(); ProductsTableAdapter pta = new ProductsTableAdapter(); cta.Fill(ds.Categories); pta.Fill(ds.Products); Session["dataset"] = ds; } return((nwndDataSet)Session["dataset"]); }
static void Main(string[] args) { SqlConnection conn = new SqlConnection(@"Data Source=(LocalDB)\SQLLocalDb;Initial Catalog=SportsStore;Integrated Security=True;Connect Timeout=15;Encrypt=False;TrustServerCertificate=False"); //SP_Demo(conn); //await ReaderAccess(conn); DsProducts ds = new DsProducts(); ProductsTableAdapter adapter = new ProductsTableAdapter(); adapter.Connection = conn; conn.Open(); adapter.Fill(ds.Products); ds.Products.AddProductsRow("Pen", "Pen with A Man", "Stationery", 12.50M); ds.WriteXml(@"C:\Lab\Products2.xml", System.Data.XmlWriteMode.DiffGram); adapter.Update(ds.Products); conn.Close(); conn.Dispose(); }
static object CreateDataSource() { var dataSource = new nwindDataSet(); var connection = new OleDbConnection(); connection.ConnectionString = Properties.Settings.Default.nwindConnectionString; CategoriesTableAdapter categories = new CategoriesTableAdapter(); categories.Connection = connection; categories.Fill(dataSource.Categories); ProductsTableAdapter products = new ProductsTableAdapter(); products.Connection = connection; products.Fill(dataSource.Products); return(dataSource); }
private BindingSource GetDataSource() { nwindDataSet dataSource = new nwindDataSet(); OleDbConnection connection = new OleDbConnection(); connection.ConnectionString = @"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=|DataDirectory|\nwind.mdb"; ProductsTableAdapter products = new ProductsTableAdapter(); products.Connection = connection; products.Fill(dataSource.Products); BindingSource bindingSource = new BindingSource(); bindingSource.DataSource = dataSource; bindingSource.DataMember = "Products"; return(bindingSource); }
//</Snippet5> //<Snippet6> private void PopulateSalesOrderInfo() { String[] tempArray = comboBox1.Text.Split(new Char[] { '|' }); menu1.Items.Clear(); orderTable = nwDataSet.Orders; orderDetailsTable = nwDataSet.Order_Details; productsTable = nwDataSet.Products; ordersTableAdapter.Fill(orderTable); detailsTableAdapter.Fill(orderDetailsTable); productsTableAdapter.Fill(productsTable); var orderQuery = from orders in orderTable.AsEnumerable() where orders.Field <string>("Customer ID") == tempArray[1] select new { OrderID = orders.Field <int>("Order ID") }; foreach (var orderItem in orderQuery) { menu1.Items.Add(CreateRibbonMenu()); RibbonMenu orderMenu = (RibbonMenu)menu1.Items.Last(); orderMenu.Dynamic = true; orderMenu.Label = orderItem.OrderID.ToString(); orderMenu.Tag = orderItem.OrderID; var productQuery = from orderDetail in orderDetailsTable.AsEnumerable() join product in productsTable.AsEnumerable() on orderDetail.Field <int>("Product ID") equals product.Field <int>("Product ID") where orderDetail.Field <int>("Order ID") == orderItem.OrderID select new { ProductName = product.Field <string>("Product Name") }; foreach (var productItem in productQuery) { RibbonButton button = CreateRibbonButton(); button.Label = productItem.ProductName; orderMenu.Items.Add(button); } } }
public void StronglyTypedDataSet() { DataSet1.CategoryDataTable CategoryDT = new DataSet1.CategoryDataTable(); CategoryTableAdapter CategoryTBAdapter = new CategoryTableAdapter(); DataSet1.ProductsDataTable ProductsDT = new DataSet1.ProductsDataTable(); ProductsTableAdapter ProductsTBAdapter = new ProductsTableAdapter(); CategoryTBAdapter.Fill(CategoryDT); ProductsTBAdapter.Fill(ProductsDT); var result = from cat in CategoryDT join prod in ProductsDT on cat.CategoryID equals prod.CategoryID where cat.CategoryID == 65985 select new { CategoryName = cat.CategoryName, ProductName = prod.ProductName, UnitPrice = prod.UnitPrice }; GridView6.DataSource = result; GridView6.DataBind(); }
private static void Main() { var dataSet = new NorthwindDataSet(); var tblAdapter = new ProductsTableAdapter(); tblAdapter.Fill(dataSet.Products); var tblAdapterCategories = new CategoriesTableAdapter(); tblAdapterCategories.Fill(dataSet.Categories); foreach (var row in dataSet.Products) { Console.WriteLine($"{row.ProductName}"); } var peterProduct = dataSet.Products.FirstOrDefault(x => x.ProductName == "Peter"); var gabrielProduct = dataSet.Products.FirstOrDefault(x => x.ProductName == "Gabriel"); if (gabrielProduct == default(NorthwindDataSet.ProductsRow) && peterProduct == default(NorthwindDataSet.ProductsRow)) { var newRow = dataSet.Products.NewProductsRow(); newRow.ProductName = "Gabriel"; newRow.Discontinued = false; newRow.CategoriesRow = dataSet.Categories.First(); dataSet.Products.AddProductsRow(newRow); } else if (peterProduct == default(NorthwindDataSet.ProductsRow)) { gabrielProduct.BeginEdit(); gabrielProduct.ProductName = "Peter"; gabrielProduct.EndEdit(); } else if (gabrielProduct == default(NorthwindDataSet.ProductsRow)) { peterProduct.Delete(); } tblAdapter.Update(dataSet); Console.ReadLine(); }
protected void Page_Load(object sender, EventArgs e) { DataSet1.CategoryDataTable Category = new DataSet1.CategoryDataTable(); CategoryTableAdapter catAdap = new CategoryTableAdapter(); DataSet1.ProductsDataTable Products = new DataSet1.ProductsDataTable(); ProductsTableAdapter prodAdap = new ProductsTableAdapter(); catAdap.Fill(Category); prodAdap.Fill(Products); var result = from item in Products select item; DataTable queriedProducts = result.CopyToDataTable<DataSet1.ProductsRow>(); queriedProducts.TableName = "queriedProducts"; DataSet1 ds = new DataSet1(); ds.Tables.Add(queriedProducts); //DataView view = result.AsDataView<DataSet1.ProductsRow>(); //view.RowFilter = "CategoryID = 65985"; GridView1.DataSource = ds.Tables["queriedProducts"]; GridView1.DataBind(); }
public ClsNorthWind() { adapter.Fill(nwd.Products); categories.Fill(nwd.Categories); }
public void ProcessRequest(HttpContext context) { _context = context; _req = context.Request; _res = context.Response; if (!string.IsNullOrEmpty(_req.QueryString["t"])) { switch (_req.QueryString["t"].ToLower()) { case "categories": if (!string.IsNullOrEmpty(_req.QueryString["id"])) { cata = new CategoriesTableAdapter(); var ds = new NorthwindDataSet(); cata.FillByCategoryID(ds.Categories, int.Parse(_req.QueryString["id"])); foreach (var item in ds.Categories) { item.Picture = null; } _res.ContentType = "text/xml"; _res.ContentEncoding = Encoding.UTF8; _res.Write("<?xml version=\"1.0\" encoding=\"utf-8\" ?>"); ds.WriteXml(_res.OutputStream); } else { cata = new CategoriesTableAdapter(); var ds = new NorthwindDataSet(); cata.Fill(ds.Categories); foreach (var item in ds.Categories) { item.Picture = null; } _res.ContentType = "text/xml"; _res.ContentEncoding = Encoding.UTF8; _res.Write("<?xml version=\"1.0\" encoding=\"utf-8\" ?>"); ds.WriteXml(_res.OutputStream); } return; case "products": if (!string.IsNullOrEmpty(_req.QueryString["id"])) { prta = new ProductsTableAdapter(); var ds = new NorthwindDataSet(); prta.FillByProductID(ds.Products, int.Parse(_req.QueryString["id"])); _res.ContentType = "text/xml"; _res.ContentEncoding = Encoding.UTF8; _res.Write("<?xml version=\"1.0\" encoding=\"utf-8\" ?>"); ds.WriteXml(_res.OutputStream); } else if (!string.IsNullOrEmpty(_req.QueryString["cid"])) { prta = new ProductsTableAdapter(); var ds = new NorthwindDataSet(); prta.FillByCategoryID(ds.Products, int.Parse(_req.QueryString["cid"])); _res.ContentType = "text/xml"; _res.ContentEncoding = Encoding.UTF8; _res.Write("<?xml version=\"1.0\" encoding=\"utf-8\" ?>"); ds.WriteXml(_res.OutputStream); } else { prta = new ProductsTableAdapter(); var ds = new NorthwindDataSet(); prta.Fill(ds.Products); _res.ContentType = "text/xml"; _res.ContentEncoding = Encoding.UTF8; _res.Write("<?xml version=\"1.0\" encoding=\"utf-8\" ?>"); ds.WriteXml(_res.OutputStream); } return; default: break; } } }
public void StronglyTypedDataSet() { DataSet1.CategoryDataTable CategoryDT = new DataSet1.CategoryDataTable(); CategoryTableAdapter CategoryTBAdapter = new CategoryTableAdapter(); DataSet1.ProductsDataTable ProductsDT = new DataSet1.ProductsDataTable(); ProductsTableAdapter ProductsTBAdapter = new ProductsTableAdapter(); CategoryTBAdapter.Fill(CategoryDT); ProductsTBAdapter.Fill(ProductsDT); var result = from cat in CategoryDT join prod in ProductsDT on cat.CategoryID equals prod.CategoryID where cat.CategoryID == 65985 select new { CategoryName = cat.CategoryName, ProductName = prod.ProductName, UnitPrice = prod.UnitPrice }; GridView6.DataSource = result; GridView6.DataBind(); }
public ClsProduct() { adapter.Fill(northwindDataSet1.Products); }
public void DataViewDemo() { DataSet1.CategoryDataTable Category = new DataSet1.CategoryDataTable(); CategoryTableAdapter catAdap = new CategoryTableAdapter(); catAdap.Fill(Category); DataSet1.ProductsDataTable Products = new DataSet1.ProductsDataTable(); ProductsTableAdapter prodAdap = new ProductsTableAdapter(); prodAdap.Fill(Products); var result = from item in Products select item; DataView view = result.AsDataView(); view.Sort = "ProductName desc"; view.RowFilter = "CategoryID = 65985"; GridView7.DataSource = view; GridView7.DataBind(); DataSet1.ProductsRow row = null; List<DataSet1.ProductsRow> myList = new List<DataSet1.ProductsRow>(); foreach (DataRowView item in view) { row = (DataSet1.ProductsRow)item.Row; myList.Add(row); } GridView8.DataSource = myList; GridView8.DataBind(); }