0

I am trying to merge two requests for searches.

This is my code

loadSearchData();

Kasa kasa = new Kasa();
DateTime startDate = textKochaniDataPrint.Value;

string razpiska;


while (startDate&&razpiska)

var AvtolistEntitiesNoShow = from a in db.Kasas
                             where (a.DateK.Date == startDate.Date) //&& (a.Razpiska == razpiska)
                             select a;



try
{
   razpiska = Convert.ToString(this.textKgkRazpiskaPrint.Text);
}
catch
{
   MessageBox.Show("Неправилен формат на кода - трябва да е цяло число!");
   return;
}

var napr = db.Kasas.Where(d => d.Razpiska == razpiska).FirstOrDefault();

try
{
   this.textKgkRazpiskaPrint.Text = kasa.Razpiska.ToString();

}
catch
{
   MessageBox.Show("Няма такова направление !");
   return;
}




}

private void loadSearchData()
{
    DateTime startDate = textKochaniDataPrint.Value;

    this.gridKochaniGlavnaKasaPrint.DataSource = db.Kasas.Where(d => d.DateK == startDate).ToList();

    string razpiska = Convert.ToString(this.textKgkRazpiskaPrint.Text);

    this.gridKochaniGlavnaKasaPrint.DataSource = db.Kasas.Where(r => r.Razpiska == razpiska).ToList();
    loadData();
}

and give me this error :

Error 1 Embedded statement cannot be a declaration or labeled statement = not a closed loop

Where is this loop or what i need to change to fix it ?

captainsac
  • 2,484
  • 3
  • 27
  • 48
  • Have you tried debugging? – Harry Jun 05 '15 at 11:50
  • 1
    Fifth line from the top, a `while` without brackets that would keep running the same query if it were allowed. Googling for the error message returns several such questions in SO, although the linked duplicate actually explains *why* the compiler complains – Panagiotis Kanavos Jun 05 '15 at 11:50
  • 2
    The posted code seems to be missing a `{` after the `while`. Is that a typo? – juharr Jun 05 '15 at 11:51
  • You should be getting an error about not being able to apply the `&&` operator to types of `string` and `DateTime` for that `while`, but oddly the compiler won't point that out until you fix the other error. – juharr Jun 05 '15 at 12:01
  • and that "not being able to apply the && operator to types of string and DateTime for that while" too – Atanas Atanasov Jun 05 '15 at 12:03
  • juharr is a typo - { on place .In code above is not copied – Atanas Atanasov Jun 05 '15 at 12:12

0 Answers0