Israel

Israel

  • 1k
  • 1.3k
  • 166.3k

search for two values once doesnt work

Apr 21 2015 2:13 PM
Hi!
 
I am trying to make search with two values once but its cant. Please have a look if I do forgot some think. 

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(); 

Answers (3)