Hola te adjunto un codigo de ejemplo, create un formulario con una label y un boton.
Segun tu comentario tu clave de la tabla es el codigo de barras, en el ejemplo es ID, lo unico esta pensado para una clave cadena, si la tuya es numerica tendras que adaptar la cadena de comando.
Código:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Data;
using System.Data.OleDb;
namespace Consulta
{
public partial class Form1 : Form
{
private static OleDbConnection dbConnection;//
private static System.Data.DataTable dbDataTable;
private static System.Data.DataSet dbDataSet;
private static OleDbDataAdapter dbDataAdapter;//
private static string CadenaConexion;//
private static OleDbDataReader col;
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
string rutaBase = "C:\\ddd.mdb";
//para access 2003
CadenaConexion = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + rutaBase;
//para access 2007
//connetionString = "Provider=Microsoft.Jet.OLEDB.12.0; Data Source=" + rutaBase;
dbConnection = new OleDbConnection(CadenaConexion);
string Campo="Email";
label1.Text = BucasDato("Nuevo", Campo, "1");
}
static internal bool CojeTabla(string NomTabla)
{
dbDataSet = new System.Data.DataSet();
dbDataAdapter = new OleDbDataAdapter("SELECT * FROM " + NomTabla, dbConnection);
OleDbCommandBuilder commandBuilder = new OleDbCommandBuilder(dbDataAdapter);
dbDataAdapter.MissingSchemaAction = MissingSchemaAction.AddWithKey;
try
{
dbDataAdapter.Fill(dbDataSet, NomTabla);
return true;
}
catch
{
return false;
}
}
static internal string BucasDato(string nomTabla, string campo, string id)
{
string tmp = null;
int n = 0;
try
{
if (dbConnection == null)
{
dbConnection = new System.Data.OleDb.OleDbConnection(CadenaConexion);
}
if (dbConnection.State != ConnectionState.Open)
{
dbConnection.Open();
}
OleDbCommand com = new OleDbCommand();
com.Connection = dbConnection;
com.CommandText = "SELECT " + campo + " FROM " + nomTabla + " WHERE ID = '" + id + "'";
CojeTabla(nomTabla);
col = com.ExecuteReader();
while (col.Read())
{
tmp = Convert.ToString(col[0]);
}
return tmp;
}
catch
{
return tmp;
}
}
}
}