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();
Con.Close();
Santhakumar MunuswamyPosted Apr 21, 2015, 2:41 PM
Try
string commandString = "select * from empresaValor where empresa ='" + txtEmpresaFacturacao.Text + "' and designacao='" + txtEmpresaFacturacao.Text + "'";
Santhakumar MunuswamyPosted Apr 22, 2015, 11:29 AM
IsraelPosted Apr 22, 2015, 10:55 AM