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;
There are some pretty good examples here:
http://www.codeproject.com/Articles/236918/Using-SQLite-embedded-database-with-entity-framewo http://www.devart.com/dotconnect/sqlite/articles/tutorial_linq.html http://vijayt.com/Post/Using-SQLite-database-in-NET-with-LINQ-to-SQL-
You might look into using EntityFramework , which makes things very easy.
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.