启用事务操作,解决批量插入或更新sqlite,mssql等数据库耗时问_MySQL
程序员文章站
2022-06-11 12:37:41
...
bitsCN.com
private void btnImport_Click(object sender, EventArgs e) { string filePath = textBox1.Text; string importPwd = txtPwd.Text; if (string.IsNullOrEmpty(filePath) || string.IsNullOrEmpty(importPwd)) { MessageBox.Show("请先导入文件,填写操作密码后,再操作!"); } else { btnImport.Text = "正在导入..."; btnImport.Enabled = false; string[] allLines = File.ReadAllLines(filePath); using (SQLiteConnection con = new SQLiteConnection(connStr)) { con.Open(); DbTransaction trans = con.BeginTransaction();//开始事务 SQLiteCommand cmd = new SQLiteCommand(con); try { for (int n = 0; n
bitsCN.com
上一篇: Photoshop打造绿叶上的漂亮的水珠