public static void AddRecords(AutoLotDataSet.InventoryDataTable table, InventoryTableAdapter adapter) { try { //add new row AutoLotDataSet.InventoryRow newRow = table.NewInventoryRow(); Console.WriteLine("Enter new color:"); newRow.Color = (string)Console.ReadLine(); Console.WriteLine("Enter new Make:"); newRow.Make = (string)Console.ReadLine(); Console.WriteLine("Enter new PetName:"); newRow.PetName = (string)Console.ReadLine(); table.AddInventoryRow(newRow); ////another way (Dont forget about position in constructor) //Console.WriteLine("Enter new color:"); //string strColor = (string)Console.ReadLine(); //Console.WriteLine("Enter new Make:"); //string strMake = (string)Console.ReadLine(); //Console.WriteLine("Enter new PetName:"); //string strPetName = (string)Console.ReadLine(); //table.AddInventoryRow(strMake, strColor, strPetName); adapter.Update(table); } catch (Exception ex) { Console.WriteLine(ex.Message); } }
public static void AddRecords( AutoLotDataSet.InventoryDataTable table, InventoryTableAdapter adapter) { try { // Get a new strongly typed row from the table. AutoLotDataSet.InventoryRow newRow = table.NewInventoryRow(); // Fill row with some sample data. newRow.Color = "Purple"; newRow.Make = "BMW"; newRow.Name = "Saku"; // Insert the new row. table.AddInventoryRow(newRow); // Add one more row, using overloaded Add method. table.AddInventoryRow("Yugo", "Green", "Zippy"); // Update database. adapter.Update(table); } catch (Exception ex) { WriteLine(ex.Message); } }
private static void RemoveRecords(AutoLotDataSet.InventoryDataTable tb, InventoryTableAdapter dAdapt) { AutoLotDataSet.InventoryRow rowToDelete = tb.FindByCarID(999); dAdapt.Delete(rowToDelete.CarID, rowToDelete.Make, rowToDelete.Color, rowToDelete.PetName); rowToDelete = tb.FindByCarID(888); dAdapt.Delete(rowToDelete.CarID, rowToDelete.Make, rowToDelete.Color, rowToDelete.PetName); }
private static void RemoveRecords(AutoLotDataSet.InventoryDataTable table, InventoryTableAdapter adapter) // Удаление записей { AutoLotDataSet.InventoryRow toDeleteRow = table.FindByCarID(999); adapter.Delete(toDeleteRow.CarID, toDeleteRow.Make, toDeleteRow.Color, toDeleteRow.PetName); toDeleteRow = table.FindByCarID(888); adapter.Delete(toDeleteRow.CarID, toDeleteRow.Make, toDeleteRow.Color, toDeleteRow.PetName); }
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 Main(string[] args) { WriteLine("***** Fun with Strongly Typed DataSets *****\n"); // Caller creates the DataSet object. var table = new AutoLotDataSet.InventoryDataTable(); // Inform adapter of the Select command text and connection. var adapter = new InventoryTableAdapter(); // Fill our DataSet with a new table, named Inventory. adapter.Fill(table); PrintInventory(table); WriteLine(); // Add rows, update and reprint. AddRecords(table, adapter); table.Clear(); adapter.Fill(table); PrintInventory(table); WriteLine(); // Remove rows we just made and reprint. RemoveRecords(table, adapter); table.Clear(); adapter.Fill(table); PrintInventory(table); WriteLine(); CallStoredProc(); 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 = "Saku"; // Вставить новую строку dt.AddInventoryRow(newRow); // Добавить еще одну строку, используя перегруженный метод добавления dt.AddInventoryRow(777, "Yugo", "Green", "Zippy"); // Обновить базу данных dAdapt.Update(dt); } catch (Exception ex) { Console.WriteLine(ex.Message); } }
// 用生成的代码插入数据 public static void AddRecords(AutoLotDataSet.InventoryDataTable tb, InventoryTableAdapter dAdapt) { try { // 从表中获取新的强类型的行 AutoLotDataSet.InventoryRow newRow = tb.NewInventoryRow(); // 使用一些示例数据填充该行 newRow.CarID = 999; newRow.Color = "Purple"; newRow.Make = "BMW"; newRow.PetName = "Saku"; // 插入新行 tb.AddInventoryRow(newRow); // 使用重载的Add方法添加另一个行 tb.AddInventoryRow(888, "Yugo", "Green", "Zippy"); // 更新数据库 dAdapt.Update(tb); } catch (Exception ex) { Console.WriteLine(ex.Message); } }
protected void btnAddItem_Click(object sender, EventArgs e) { try { DataRow Inventorydata = dsInventory.Inventory.NewRow(); // Create a new row of service_order table in memory //update record with user's input Inventorydata[5] = this.ddlProducts.SelectedValue; Inventorydata[3] = this.ddlMeasures.SelectedValue; Inventorydata[1] = this.txtQuantity.Text; Inventorydata[2] = this.txtSize.Text; Inventorydata[4] = this.txtPrice.Text; ProductTableAdapter daProduct = new ProductTableAdapter(); InventoryTableAdapter inventoryTable = new InventoryTableAdapter(); dsInventory.Inventory.Rows.Add(Inventorydata); // add the rows to the dataset inventoryTable.Update(Inventorydata); // Call update method on the service adapter so it updates the table in memory ( All changes made are applied - CRUD) dsInventory.AcceptChanges(); // Call accept method on the dataset so it update the chanmges to the database lblMessage.Text = "Created 1"; //Refresh the page to show the record being deleted Response.Redirect("Default.aspx"); // Redirect the user to dexpage on to show created data lblMessage.Text = "Created"; } catch { lblMessage.Text = "Failed"; } }
static void Main(string[] args) { Console.WriteLine("***** Fun with Strongly Typed DataSets *****\n"); AutoLotDataSet.InventoryDataTable table = new AutoLotDataSet.InventoryDataTable(); InventoryTableAdapter dAdapt = new InventoryTableAdapter(); dAdapt.Fill(table); // Add rows, update, and reprint. AddRecords(table, dAdapt); table.Clear(); dAdapt.Fill(table); PrintInventory(table); Console.ReadLine(); RemoveRecords(table, dAdapt); dAdapt.Fill(table); PrintInventory(table); Console.ReadLine(); CallStoredProc(); Console.ReadLine(); }
static void Main(string[] args) { Console.WriteLine("***** Fun with Strongly Typed DataSets *****\n"); AutoLotDataSet.InventoryDataTable table = new AutoLotDataSet.InventoryDataTable(); InventoryTableAdapter dAdapt = new InventoryTableAdapter(); dAdapt.Fill(table); PrintInventory(table); // Добавить строки, обновить и вывести повторно AddRecords(table, dAdapt); table.Clear(); dAdapt.Fill(table); PrintInventory(table); // Удалить строки, обновить и вывести повторно RemoveRecords(table, dAdapt); table.Clear(); dAdapt.Fill(table); PrintInventory(table); CallStoredProc(); Console.ReadLine(); }
static void Main(string[] args) { Console.WriteLine("***** Fun with Strongly Typed DataSets *****\n"); // Caller creates the DataSet object. AutoLotDataSet.InventoryDataTable table = new AutoLotDataSet.InventoryDataTable(); // Inform adapter of the Select command text and connection. InventoryTableAdapter dAdapt = new InventoryTableAdapter(); // Fill our DataSet with a new table, named Inventory. dAdapt.Fill(table); PrintInventory(table); Console.WriteLine(); // Add rows, update and reprint. AddRecords(table, dAdapt); table.Clear(); dAdapt.Fill(table); PrintInventory(table); Console.WriteLine(); // Remove rows we just made and reprint. RemoveRecords(table, dAdapt); table.Clear(); dAdapt.Fill(table); PrintInventory(table); Console.WriteLine(); CallStoredProc(); Console.ReadLine(); }
private static void AddRowWithTypedDataSet() { var inventoryDataAdapter = new InventoryTableAdapter(); var inventory = inventoryDataAdapter.GetData(); inventory.AddInventoryRow("Ford", "Yellow", "Sal"); inventoryDataAdapter.Update(inventory); }
private static void AddRecords(AutoLotDataSet.InventoryDataTable table, InventoryTableAdapter adapter) // Добавление записей { AutoLotDataSet.InventoryRow newRow = table.NewInventoryRow(); // Получение из таблицы новой строго типизированной строки newRow.CarID = 999; // Заполнение строки данными newRow.Color = "Purple"; newRow.Make = "BMW"; newRow.PetName = "Saku"; table.AddInventoryRow(newRow); // Вставка новой строки table.AddInventoryRow(888, "Yugo", "Green", "Zippy"); adapter.Update(table); // Обновление базы данных }
static void Main(string[] args) { AutoLotDataSet.InventoryDataTable table = new AutoLotDataSet.InventoryDataTable(); InventoryTableAdapter adapter = new InventoryTableAdapter(); AddRecords(table, adapter); table.Clear(); adapter.Fill(table); PrintInventory(table); Console.ReadLine(); }
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); } }
private static void RemoveRow(AutoLotDataSet.InventoryDataTable table, InventoryTableAdapter adapter, int n) { var rows = table.Rows; if ((n = ((AutoLotDataSet.InventoryRow)rows[rows.Count - n]).CarId) > 12) { WriteLine($"- remove row with CarId {n}"); AutoLotDataSet.InventoryRow row = table.FindByCarId(n); adapter.Delete(row.CarId, row.Make, row.Color, row.PetName); } }
private static void AddRecords(AutoLotDataSet.InventoryDataTable table, InventoryTableAdapter adapter) { AutoLotDataSet.InventoryRow newRow = table.NewInventoryRow(); newRow.Color = "Purple"; newRow.Make = "BMW"; newRow.PetName = "Saku"; table.AddInventoryRow(newRow); table.AddInventoryRow("Yugo", "Green", "Zippy"); adapter.Update(table); }
private static void ShowTable() { ForegroundColor = ConsoleColor.Yellow; WriteLine("=> Diaplay Inventory Data Using AutoLogDAL library version 3"); var table = new AutoLotDataSet.InventoryDataTable(); var adapter = new InventoryTableAdapter(); adapter.Fill(table); PrintInventory(table); }
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 RemoveRecords(AutoLotDataSet.InventoryDataTable tb, InventoryTableAdapter dAdapt) { try { AutoLotDataSet.InventoryRow rowToDelete = tb.FindByCarID(991); dAdapt.Delete(rowToDelete.CarID, rowToDelete.Make, rowToDelete.Color, rowToDelete.PetName); rowToDelete = tb.FindByCarID(887); dAdapt.Delete(rowToDelete.CarID, rowToDelete.Make, rowToDelete.Color, rowToDelete.PetName); } catch (Exception ex) { Console.WriteLine(ex.Message); } }
//connection to the database private void get_data() { ds = new DataSet1(); st = new InventoryTableAdapter(); st.Fill(ds.Inventory); ct = new SuppliersTableAdapter(); ct.Fill(ds.Suppliers); et = new EmployeesTableAdapter(); et.Fill(ds.Employees); }
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(); }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { //checking if its not a postback before newing makes the list persistant while building it //it will reset when coming from elsewhere onOrders = new List <On_Order>(); } //defaults date ordered to now txtDateOrdered.Text = DateTime.Now.Date.ToString("yyyy-MM-dd"); InventoryTableAdapter inventory = new InventoryTableAdapter(); inventory.Fill(dsInventory.Inventory); }
public static void RemoveRecord(AutoLotDataSet.InventoryDataTable table, InventoryTableAdapter adapter) { try { AutoLotDataSet.InventoryRow rowToDelete = table.FindByCarId(1); adapter.Delete(rowToDelete.CarId, rowToDelete.Make, rowToDelete.Color, rowToDelete.PetName); rowToDelete = table.FindByCarId(2); adapter.Delete(rowToDelete.CarId, rowToDelete.Make, rowToDelete.Color, rowToDelete.PetName); } catch (Exception ex) { WriteLine(ex.Message); } }
private static void RemoveRecords(AutoLotDataSet.InventoryDataTable table, InventoryTableAdapter adapter) { try { Write("Enter ID of car to delete: "); string carID = ReadLine() ?? "0"; AutoLotDataSet.InventoryRow rowToDelete = table.FindByCarId(int.Parse(carID)); adapter.Delete(rowToDelete.CarId, rowToDelete.Make, rowToDelete.Color, rowToDelete.PetName); } catch (Exception ex) { WriteLine(ex.Message); } }
private static void AddRows() { ForegroundColor = ConsoleColor.Cyan; WriteLine("=> Add Two Rows Using AutoLogDAL library version 3"); var table = new AutoLotDataSet.InventoryDataTable(); var adapter = new InventoryTableAdapter(); adapter.Fill(table); AddRecords(table, adapter); table.Clear(); adapter.Fill(table); PrintInventory(table); }
private static void DelRows() { ForegroundColor = ConsoleColor.DarkYellow; WriteLine("=> Delete Records Using AutoLogDAL library"); var table = new AutoLotDataSet.InventoryDataTable(); var adapter = new InventoryTableAdapter(); adapter.Fill(table); DelRecords(table, adapter); table.Clear(); adapter.Fill(table); PrintInventory(table); }
static void Main(string[] args) { Console.WriteLine("**********Work with Strongly Typed DataSet***********"); var table = new AutoLotDataSet.InventoryDataTable(); var adapter = new InventoryTableAdapter(); //AddRecords(table, adapter); adapter.Fill(table); RemoveRecords(table, adapter); adapter.Fill(table); PrintInventory(table); Console.ReadLine(); }
static void Main(string[] args) { Console.WriteLine("***** Fun with Strongly Typed DataSets *****\n"); // Caller creates the DataSet object. var table = new AutoLotDataSet.InventoryDataTable(); // Inform adapter of the Select command text and connection. var adapter = new InventoryTableAdapter(); // Fill our DataSet with a new table, named Inventory. adapter.Fill(table); PrintInventory(table); 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(); }
private static void RemoveRecords(AutoLotDataSet.InventoryDataTable tb, InventoryTableAdapter adapter) { try { Console.WriteLine("Enter carId what you want delete: "); int carIdToDelete = int.Parse(Console.ReadLine().ToString()); AutoLotDataSet.InventoryRow rowToDelete = tb.FindByCarId(carIdToDelete); adapter.Delete(rowToDelete.CarId, rowToDelete.Make, rowToDelete.Color, rowToDelete.PetName); adapter.Update(tb); } catch (Exception ex) { Console.WriteLine(ex.Message); } }
private static void RemoveRecords(AutoLotDataSet.InventoryDataTable table, InventoryTableAdapter adapter) { try { AutoLotDataSet.InventoryRow rowToDelete = table.FindByCarId(table.Last().CarId); adapter.Delete(rowToDelete.CarId, rowToDelete.Make, rowToDelete.Color, rowToDelete.Name); rowToDelete = table.FindByCarId(table.Last().CarId - 1); adapter.Delete(rowToDelete.CarId, rowToDelete.Make, rowToDelete.Color, rowToDelete.Name); adapter.Update(table); } catch (Exception ex) { WriteLine(ex.Message); } }
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(); }
static void Main(string[] args) { AutoLotDataSet.InventoryDataTable table = new AutoLotDataSet.InventoryDataTable(); InventoryTableAdapter dAdapt = new InventoryTableAdapter(); AddRecords(table, dAdapt); table.Clear(); dAdapt.Fill(table); RemoveRecords(table, dAdapt); PrintInventory(table); CallStoreProc(); 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); } }
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(); }