c# ACCESS 查询数据

using System.Data.OleDb;
  private void 查询条形码()
        {
            //创建连接对象
            OleDbConnection conn = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=d:/姜民强-油箱盖标签自动分拣/条形码数据.mdb;Persist Security Info=False");
            conn.Open();
          
            string sql;
           
            sql = " SELECT top 1 条形码表.条形码 FROM 条形码表";
            

            OleDbCommand cm = new OleDbCommand(sql, conn);
            OleDbDataReader reader = cm.ExecuteReader();
            reader.Read();

            TXT条码.Text = reader.GetString(0);
            conn.Close();
            //richTextBox1.Text = DateTime.Now.ToLongTimeString() + "保存车号为:" + str + "\r\n" + richTextBox1.Text;
        }


        private void button1_Click(object sender, EventArgs e)
        {
            查询条形码();

        }

你可能感兴趣的:(access)