Esempio n. 1
0
        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();
        }
Esempio n. 2
0
        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();
        }
Esempio n. 3
0
 private void button1_Click(object sender, EventArgs e)
 {
     pta.Update(sado.Products);
     MessageBox.Show("Sauvegarde Réussie");
 }