简体   繁体   English

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

[英]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. 我需要使用一些文本字段,然后使用LINQ to SQL将数据插入到SQLite数据库中。 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();

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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