做了一个windows的数据库录入小工具,尝试了下使用C#来写程序

C#的控件绑定数据源很好用

private SQLiteConnection conn = null;
public SQLiteDataAdapter dao;
public DataSet ds;
public SQLiteCommand command;
public SQLiteCommandBuilder sqlitecmdBuilder;
public void query(String namekey, String tablename, String address_limit)
{
    String sql = "SELECT * FROM " + tablename + " where namec like '%" + namekey + "%'"+ address_limit + " limit 0,100;";
    try
    {
        conn = new SQLiteConnection(ConnStr);
        conn.Open();

        dao = new SQLiteDataAdapter(sql, conn);
        ds = new DataSet();
        dao.Fill(ds, tablename);

        sqlitecmdBuilder = new SQLiteCommandBuilder(dao);
        dao.UpdateCommand = sqlitecmdBuilder.GetUpdateCommand();
        dao.DeleteCommand = sqlitecmdBuilder.GetDeleteCommand();
    }
    catch (System.Exception ex)
    {
    }
    finally
    {
    }
}
private void button_query_Click(object sender, EventArgs e)
{
    
    String address_limit = "";
    if (this.checkBox_address1.Checked)
    {
        address_limit += " and address1 like '%" + textBox_address1.Text + "%'";
    }
    if (this.checkBox_address2.Checked)
    {
        address_limit += " and address2 like '%" + textBox_address2.Text + "%'";
    }
    if (this.checkBox_address3.Checked)
    {
        address_limit += " and address3 like '%" + textBox_address3.Text + "%'";
    }

    sv.query(this.textBox_key.Text, this.textBox_dbname.Text,address_limit);
    this.dataGridView1.AutoGenerateColumns = true;
    if (sv.ds != null)
    {
        this.dataGridView1.DataSource = sv.ds.Tables[0];
    }
    else
    {
        MessageBox.Show("请检查数据库名和表名称是否正确");
    }

}

短短几行完成了界面更新数据库 怪不得c#被成为最优雅的语言

point.rar