1.我建立了一个access数据库并使用程序进行调用,使用datagridview可以显示出来
2.我的问题是怎么通过一个button按钮对数据库内容进行筛选调用,并且可以将其显示到textbox中
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Data.OleDb;
namespace text01
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
OleDbConnection thisConnection = new OleDbConnection(@"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Users\赵吉利15067\Desktop\access数据库文件夹\20190225-数据完整版1.mdb");
string sql = "select * from 总表(二字词、三字词、四字词)";
OleDbDataAdapter thisAdapter = new OleDbDataAdapter(sql, thisConnection);
System.Data.DataSet thisDataSet = new System.Data.DataSet();
thisAdapter.Fill(thisDataSet, "table");
DataTable dt = thisDataSet.Tables["table"];
this.dataGridView1.DataSource = dt;
/*设置抽取选项,按照属性 单元 序号的顺序抽取*/
thisConnection.Close();
}
private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e)
{
}
}
}
主要目的是通过一个按钮实现对数据库的调用,并且显示在空白文本框里面