使用LINQ to SQL将数据插入SQLite DB

时间:2014-09-24 02:48:22

标签: c# linq sqlite windows-runtime

我需要使用一些文本字段并使用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; 

2 个答案:

答案 0 :(得分:1)

答案 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();