简体   繁体   中英

Insert data into a SQLite DB using LINQ to SQL

I need to take some text fields and insert that data into a SQLite DB using LINQ to SQL. This is what I have so far:

var ordersDB = new SQLite.SQLiteConnection(orderPath);

Orders ord = new Orders();

ord.custNum = tblCustomerNumber.Text;
ord.itemNum = tbxEnterItem.Text;
ord.itemQty = tbxQty.Text; 

This is how I got it working:

var ordersDB = new SQLite.SQLiteConnection(orderPath);

Orders ord = new Orders();


ord.custNum = tblCustomerNumber.Text;
ord.itemNum = tbxEnterItem.Text;
ord.itemQty = tbxQty.Text;
ord.itemDesc = tblOrderItemDesc.Text;
ord.itemCost = tblOrderItemCost.Text;
ord.orderDate = DateTime.Now.ToString();


ordersDB.BeginTransaction();
ordersDB.Insert(ord);
ordersDB.Commit();

ordersDB.Dispose();
ordersDB.Close();

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM