I
I
iamdivine2020-05-12 12:50:58
MySQL
iamdivine, 2020-05-12 12:50:58

Correct return of data in the request?

Hello, I'm a little confused. It does not return true or false, everything is fine in queries, if I manually set a boolean variable, the recording goes on, and if in this way, then it is always false. Please fix the code

private bool blocked;
private bool IsRibakZablokirovan(int currNumberDriver)
{
 SQLiteConnection local = null;
 try
 {
  local = new SQLiteConnection(ConnectionString.SqliteDBProvider);
  using(var taJournal = new KPP.Data.DBclientTableAdapters._РыбакОхотникTableAdapter())
  {
   taJournal.Connection = local;
   var ribaks = taJournal.GetDataByNumberPerson(currNumberDriver);
   foreach(var ribak in ribaks) // сама проверка, в бд в поле Заблокирован записано true
   {
    if (ribak.IsblockNull()) blocked = false;
    if (ribak.block.ToString() == "true") blocked = true;
    //return blocked;
    MessageBox.Show("mq1", $ "{blocked}", MessageBoxButtons.OK);

   }
  }
 } finally
 {
  if (local != null)
  {
   local.Close();
   local.Dispose();
  }
 }
 MessageBox.Show("1", $ "{blocked.ToString()}", MessageBoxButtons.OK); // это не важно
 return blocked; // возврат булевой переменной
}

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question