string connectionString = @"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\LunaVisa\Visa\Visa\App_Data\visa.mdb;Persist Security Info=False";
OleDbConnection sqlCon = newOleDbConnection(connectionString);
Con.Open();
string commandString = "select * from empresaValor where designacao ='" + cbxDesignacaoFacturacao.Text + "'";
string commandString = "select * from empresaValor where empresa ='" + txtEmpresaFacturacao.Text + " and designacao= " + txtEmpresaFacturacao.Text + "'";// Here the problem
OleDbCommand sqlCmd = newOleDbCommand(commandString, sqlCon);
OleDbDataReader read = sqlCmd.ExecuteReader();
if (read.HasRows)
{
while (read.Read())
txtPUFacturacao.Text = read["valor"].ToString(); // it will show the code
}
else
MessageBox.Show("Essa designação " + cbxDesignacaoFacturacao.Text + " nao foi encontrada na lista. Obrigado!");
read.Close();