Exemple #1
0
        public static void AddRecords(AutoLotDataSet.InventoryDataTable tb, InventoryTableAdapter dAdapt)
        {
            try
            {
                // Get a new strongly typed row from the table.
                AutoLotDataSet.InventoryRow newRow = tb.NewInventoryRow();

                // Fill row with some sample data.
                newRow.CarID = 999;
                newRow.Color = "Purple";
                newRow.Make = "BMW";
                newRow.PetName = "Saku";

                // Insert the new row.
                tb.AddInventoryRow(newRow);

                // Add one more row, using overloaded Add method.
                tb.AddInventoryRow(12345, "Yugo", "Green", "Zippy");

                // Update database.
                dAdapt.Update(tb);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
        }
 static void ShowBlackCarsStronglyTyped(AutoLotDataSet.InventoryDataTable data) {
     var cars = from car in data.AsEnumerable()
                where car.Color == "Black"
                select new { ID = car.CarID, Make = car.Make };
     Console.WriteLine("Black cars:");
     foreach (var item in cars) {
         Console.WriteLine("-> CarID = {0} is {1}", item.ID, item.Make);
     }
 }
        private static void RemoveRecords(AutoLotDataSet.InventoryDataTable dt, InventoryTableAdapter dAdapt) {
            try {
                AutoLotDataSet.InventoryRow rowToDelete = dt.FindByCarID(999);
                dAdapt.Delete(rowToDelete.CarID, rowToDelete.Make, rowToDelete.Color, rowToDelete.PetName);

                rowToDelete = dt.FindByCarID(995);
                dAdapt.Delete(rowToDelete.CarID, rowToDelete.Make, rowToDelete.Color, rowToDelete.PetName);
            } catch (Exception ex) {
                Console.WriteLine(ex.Message);
            }
        }
        static void Main(string[] args) {
            AutoLotDataSet ds = new AutoLotDataSet();
            InventoryTableAdapter da = new InventoryTableAdapter();
            AutoLotDataSet.InventoryDataTable data = da.GetData();
            PrintAllCarIDs(data);

            ShowBlackCars(data);
            ShowBlackCars2(data);
            ShowBlackCarsStronglyTyped(data);
            BuildDataTableFromQuery(data);
            Console.ReadLine();
        }
        private static void PrintInventory(AutoLotDataSet.InventoryDataTable dt) {
            for (int curCol = 0; curCol < dt.Columns.Count; curCol++) {
                Console.Write(dt.Columns[curCol].ColumnName + "\t");
            }
            Console.WriteLine("\n-------------------------------------------");

            for (int curRow = 0; curRow < dt.Rows.Count; curRow++) {
                for (int curCol = 0; curCol < dt.Columns.Count; curCol++) {
                    Console.Write(dt.Rows[curRow][curCol].ToString() + "\t");
                }
                Console.WriteLine();
            }
        }
Exemple #6
0
        private static void Main(string[] args)
        {
            Console.WriteLine("***** LINQ over DataSet ***** \n");

            var dal          = new AutoLotDataSet();
            var tableAdapter = new InventoryTableAdapter();
            var data         = tableAdapter.GetData();

            PrintAllCarIds(data);
            ShowRedCars(data);

            Console.ReadLine();
        }
        static void Main(string[] args)
        {
            Console.WriteLine("***** LINQ over DataSet *****\n");

            //  获取包含AutoLot数据库中当期Inventory的强类型DataTable
            AutoLotDataSet        dal = new AutoLotDataSet();
            InventoryTableAdapter da  = new InventoryTableAdapter();

            AutoLotDataSet.InventoryDataTable data = da.GetData();

            PrintAllCarIDs(data);
            ShowRedCars(data);
            BuildDataTableFromQuery(data);
            Console.ReadLine();
        }
Exemple #8
0
        static void Main(string[] args)
        {
            WriteLine("**** LINQ over DataSet ****\n");

            //Get a strongly typed DataTable containing the current Inventory
            // of the AutoLot Database
            AutoLotDataSet        dal          = new AutoLotDataSet();
            InventoryTableAdapter tableAdapter = new InventoryTableAdapter();

            AutoLotDataSet.InventoryDataTable data = tableAdapter.GetData();

            //Invoke the methods that follow here!
            PrintAllCarIDs(data);
            ShowRedCars(data);
            ReadLine();
        }
Exemple #9
0
        private static void UseEnumerable()
        {
            ForegroundColor = ConsoleColor.Yellow;
            WriteLine("=> Linq-Complatible DataTable");

            AutoLotDataSet        dal     = new AutoLotDataSet();
            InventoryTableAdapter adapter = new InventoryTableAdapter();

            AutoLotDataSet.InventoryDataTable data = adapter.GetData();

            PrintAllCarIDs(data);
            ShowBalckCars(data);
            ShowBlackSafety(data);

            BuildDataTableFromQuery(data);
        }
Exemple #10
0
        static void Main(string[] args)
        {
            Console.WriteLine("****** LINQ over DataSet ******\n");

            // Получить строго типизированный объект DataTable, содержащий
            // текущие данные таблицы Inventory из базы данных AutoLot
            AutoLotDataSet        dal = new AutoLotDataSet();
            InventoryTableAdapter da  = new InventoryTableAdapter();

            AutoLotDataSet.InventoryDataTable data = da.GetData();

            PrintAllCarIDs(data);
            ShowBlackCars(data);
            BuildDataTableFromQuery(data);
            Console.ReadLine();
        }
Exemple #11
0
        static void Main(string[] args)
        {
            Console.WriteLine("***** LINQ over DataSet *****\n");

            // Get a strongly typed DataTable containing the current Inventory
            // of the AutoLot database.
            AutoLotDataSet        dal = new AutoLotDataSet();
            InventoryTableAdapter da  = new InventoryTableAdapter();

            AutoLotDataSet.InventoryDataTable data = da.GetData();

            // Invoke the methods that follow here!
            ShowBlackCars(data);
            BuildDataTableFromQuery(data);

            Console.ReadLine();
        }
Exemple #12
0
        static void Main(string[] args)
        {
            WriteLine("***** LINQ over DataSet ******\n");

            //Get a strongly typed DataTable containing the current Inventory of the AutoLot database
            AutoLotDataSet        dal          = new AutoLotDataSet();
            InventoryTableAdapter tableAdapter = new InventoryTableAdapter();

            AutoLotDataSet.InventoryDataTable data = tableAdapter.GetData();

            //Methods
            PrintAllCarIDs(data);
            ShowBlackCars(data);
            BuildDataTableFromQuery(data);

            ReadLine();
        }
Exemple #13
0
        static void Main()
        {
            AutoLotDataSet        dal = new AutoLotDataSet();
            InventoryTableAdapter da  = new InventoryTableAdapter();

            AutoLotDataSet.InventoryDataTable data = da.GetData();

            PrintAllCarIds(data);
            Console.WriteLine();

            ShowRedCars(data);
            Console.WriteLine();

            BuildDataTableFromQuery(data);
            Console.WriteLine();

            Console.ReadLine();
        }
        private static void AddRecords(AutoLotDataSet.InventoryDataTable dt, InventoryTableAdapter dAdapt) {
            try {
                AutoLotDataSet.InventoryRow newRow = dt.NewInventoryRow();

                newRow.CarID = 999;
                newRow.Color = "Purple";
                newRow.Make = "BMW";
                newRow.PetName = "Seku";

                dt.AddInventoryRow(newRow);


                dt.AddInventoryRow(995, "Yugo", "Green", "Zippy");

                dAdapt.Update(dt);
            } catch (Exception ex) {
                Console.WriteLine(ex.Message);
            }
        }
Exemple #15
0
        static void Main(string[] args)
        {
            Console.WriteLine("***** LINQ over DataSet *****\n");

            // Get a strongly typed DataTable containing the current Inventory
            // of the AutoLot database.
            AutoLotDataSet dal = new AutoLotDataSet();
            InventoryTableAdapter da = new InventoryTableAdapter();
            AutoLotDataSet.InventoryDataTable data = da.GetData();

            // Print all car ids.
            PrintAllCarIDs(data);
            Console.WriteLine();

            // Show all red cars.
            ShowRedCars(data);
            Console.WriteLine();

            BuildDataTableFromQuery(data);
            Console.WriteLine();

            Console.ReadLine();
        }
Exemple #16
0
        static void Main(string[] args)
        {
            Console.WriteLine("***** LINQ over DataSet *****\n");

            // Get a strongly typed DataTable containing the current Inventory
            // of the AutoLot database.
            AutoLotDataSet        dal = new AutoLotDataSet();
            InventoryTableAdapter da  = new InventoryTableAdapter();

            AutoLotDataSet.InventoryDataTable data = da.GetData();

            // Print all car ids.
            PrintAllCarIDs(data);
            Console.WriteLine();

            // Show all red cars.
            ShowRedCars(data);
            Console.WriteLine();

            BuildDataTableFromQuery(data);
            Console.WriteLine();

            Console.ReadLine();
        }