string connectionString = @"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\lunaoffice\lunaoffice\\app_data\office.mdb;Persist Security Info=False";
OleDbConnection sqlCon = new OleDbConnection(connectionString);
sqlCon.Open();
string commandString = "select * from stock order by N_O where code ='" + txtCode.Text + "'";
OleDbCommand sqlCmd = new OleDbCommand(commandString, sqlCon);
OleDbDataReader read = sqlCmd.ExecuteReader();
if (read.HasRows)
{
while (read.Read())
{
txtNumber.Text = read["number"].ToString();
txtProduct.Text = read["product"].ToString();
}
}
else
{
MessageBox.Show("This code " + txtCode.Text + " doenst exist");
}
read.Close();
sqlCon.Close();