对不起,我无法在网站上找到我的问题答案。
我有一个项目,通过使用Sqlite数据库提供和检索一些信息(文本类型数据)。
但是我想通过点击该图像的字段(下面的代码中的docImage)将图片添加到其中一列并进行检索。
你能帮我吗?
private void LoadData()
{
SetConnection();
sql_con.Open();
sql_cmd = sql_con.CreateCommand();
string CommandText = "select id, docImage, letternum, name, female, personnamber, organname, officename, numberofdoc, numberofbox, ticket, docdate from mains";
DB = new SQLiteDataAdapter(CommandText,sql_con);
DS.Reset();
DB.Fill(DS);
DT= DS.Tables[0];
Grid.DataSource = DT;
sql_con.Close();
}
private void SetConnection()
{
sql_con = new SQLiteConnection("Data Source=DemoT.db;Version=3;New=False;Compress=True;");
}
private void ExecuteQuery(string txtQuery)
{
SetConnection();
sql_con.Open();
sql_cmd = sql_con.CreateCommand();
sql_cmd.CommandText=txtQuery;
sql_cmd.ExecuteNonQuery();
sql_con.Close();
}
private void Form1_Load(object sender, EventArgs e)
{
LoadData();
}
private void Add()
{
string txtSQLQuery = "insert into mains (docImage, letternum, name, female, personnamber, organname, officename, numberofdoc, numberofbox, ticket, docdate ) values ('" + txtDesc11.Text + "','" + txtDesc.Text + "','" + txtDesc2.Text + "','" + txtDesc3.Text + "','" + txtDesc4.Text + "','" + txtDesc5.Text + "','" + txtDesc6.Text + "','" + txtDesc7.Text + "','" + txtDesc8.Text + "','" + txtDesc9.Text + "','" + txtDesc10.Text + "')";
ExecuteQuery(txtSQLQuery);
}
private void btnAdd_Click(object sender, EventArgs e)
{
Add();
LoadData();
btnAdd.Enabled = false;
btnNew.Enabled = true;
btnEdit.Enabled = false;
txtDesc.Text = string.Empty;
txtDesc2.Text = string.Empty;
}