C#查询ACCESS数据库 这是窗体的代码
usingSystem;usingSystem.Collections.Generic;usingSystem.ComponentModel;usingSystem.Da...
using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Text; using System.Windows.Forms; using System.Data.OleDb; using System.IO; namespace 鞋店信息管理系统 { public partial class Form1 : Form { private DataSet dsnew; private OleDbCommand command = new OleDbCommand(); private OleDbConnection connection; private OleDbDataAdapter adapter; private DataTable thetable = new DataTable(); public Form1() { InitializeComponent(); } private void Form1_Load(object sender, EventArgs e) { // TODO: 这行代码将数据加载到表“mdb1DataSet.inf”中。您可以根据需要移动或移除它。 this.infTableAdapter.Fill(this.mdb1DataSet.inf); } private void button1_Click(object sender, EventArgs e) { string con = "Select * from inf where num= '" + textBox1.Text + "'"; connection = new OleDbConnection(); connection.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source= E:\\0915070241苏莹\\鞋店信息管理系统\\mdb1.mdb"; connection.Open(); command.Connection = connection; command.CommandType = CommandType.Text; command.CommandText = con; adapter = new OleDbDataAdapter("Select * From inf", connection); adapter.SelectCommand = command; dsnew = new DataSet(); adapter.Fill(dsnew, "mdb1"); thetable = dsnew.Tables["mdb1"]; dataGridView1.DataSource = thetable; } } } 点击查询之后出现这个错误提示 请高手帮助啊~~
展开
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询