コード例 #1
0
        public static MyDoublyLinkedList <Customer> Load()
        {
            MyDoublyLinkedList <Customer> customersTable = new MyDoublyLinkedList <Customer>();

            string location         = "Northwind.mdb";
            string connectionString = @"Provider=Microsoft.Jet.OLEDB.4.0; data source=" + location;
            string sSql             = "select * from Customers";

            OleDbConnection  con     = new OleDbConnection(connectionString);
            OleDbCommand     myCmd   = new OleDbCommand(sSql, con);
            OleDbDataAdapter adapter = new OleDbDataAdapter(); //יצירת אוביקט

            adapter.SelectCommand = myCmd;                     // command קישור ל
            DataSet dataset = new DataSet();                   // יצירת טבלה בזיכרון

            adapter.Fill(dataset, "tblusers");                 //מילוי הטבלה ומתן שם
            dataset.Tables["tblusers"].PrimaryKey = new DataColumn[] { dataset.Tables["tblusers"].Columns["UserID"] };

            foreach (DataRow row in dataset.Tables[0].Rows)
            {
                customersTable.Insert(new Customer(row[0].ToString(), row[1].ToString(),
                                                   row[2].ToString(), row[9].ToString()));
            }

            return(customersTable);
        }
コード例 #2
0
ファイル: MyDB.cs プロジェクト: Boris-Simkin/WpfDataManager
        /// <summary>
        /// Insert Customers as MyDoublyLinkedList
        /// and return true if some of customers ID were reserved
        /// </summary>
        /// <param name="customersTable">MyDoublyLinkedList<Customer></param>
        /// <returns></returns>
        public bool Insert(MyDoublyLinkedList <Customer> customersTable)
        {
            bool reservedID = false;

            foreach (var customer in customersTable)
            {
                if (!dictCustomerID.ContainsKey(customer.CustomerID))
                {
                    _customersTable.Insert(customer);
                    AddToDictionaries(_customersTable.Head, CustomerField.All);
                }
                else
                {
                    reservedID = true;
                }
            }
            return(reservedID);
        }