C#SQLite 批量插入 求教

如题所述

namespace CplusData
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
static SQLiteConnection conn = new SQLiteConnection("Data Source=F:\\Project\\Data\\test;Version=3;");
SQLiteCommand cmd = new SQLiteCommand("select * from usertab", conn);
SQLiteDataAdapter sda = new SQLiteDataAdapter();
DataSet ds=new DataSet();
private void Form1_Load(object sender, EventArgs e)
{
conn.Open();
sda.SelectCommand = cmd;
sda.Fill(ds,"usertab");
this.dataGridView1.DataSource = ds;
this.dataGridView1.DataMember = "usertab";
conn.Close();

}
private void button1_Click(object sender, System.EventArgs e)
{
//主要是这个对象的使用,可以实现在dataGridView1控件中新加入的数据可以更新到数据库中
SQLiteCommandBuilder scb = new SQLiteCommandBuilder(sda);
scb.GetUpdateCommand();
sda.Update(ds,"usertab");
}

}
}
温馨提示:答案为网友推荐,仅供参考
相似回答