我需要使用一些文本字段并使用LINQ to SQL将该数据插入到SQLite数据库中。这就是我到目前为止所做的:
var ordersDB = new SQLite.SQLiteConnection(orderPath);
Orders ord = new Orders();
ord.custNum = tblCustomerNumber.Text;
ord.itemNum = tbxEnterItem.Text;
ord.itemQty = tbxQty.Text;
答案 0 :(得分:1)
这里有一些不错的例子:
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-
您可以考虑使用EntityFramework,这会让事情变得非常简单。
答案 1 :(得分:1)
这就是我的工作方式:
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();