c# - Creating a progress bar for SQL query (using ADO.NET) -


i'm trying make progress bar sql query don't know start. have tried implementing backgroundworker can't seem work.

i'm using vs 2010 .net 4.0

treinen trein = listboxvoertuignr.selecteditem treinen; list<string> treinenids = new list<string>(); foreach (var item in listboxvoertuignr.selecteditems) {     treinenids.add(item.tostring()); }  fouten = eventsentities.foutens; category = eventsentities.category_mmap;   ienumerable<dynamic> foutenresultaat = new list<dynamic>();  foutenresultaat = (from x in treinen     join fout in fouten     on x.treinid equals fout.treinid     datestart <= fout.datum && dateend >= fout.datum     && treinenids.contains(fout.treinen.name)     && fout.omschrijving.contains(textboxfilteromschrijving.text)     && fout.foutcode.contains(textboxfilterfout.text)     && fout.module.contains(textboxfiltermodule.text)     orderby fout.datum descending, fout.time descending      join cat in category     on fout.foutcode equals cat.foutcode      select new     {         datum = fout.datum,         time = fout.time,         foutcode = fout.foutcode,         omschrijving = fout.omschrijving,         module = fout.module.toupper(),         foutid = fout.foutid,         name = x.name,         category = cat.cat_mmap     });  getgraad(foutenresultaat); 

in getgraad() read data sql database gets placed in list. custom list because gets populated values excel file.

private void getgraad(ienumerable<dynamic> mijnresultaten) {     foreach (dynamic item in mijnresultaten)     {         string graad = "";         string toolbox = "";         if (item.module.contains("_"))             modnaam = item.module.split('_');         else if (item.module.contains(" "))             modnaam = item.module.split(' ');             string compare = modnaam[0].substring(0, modnaam[0].length - 1).tostring();         if (compare == "mpu")         {              var index = properties.settings.default.listfoutcodempu.findindex(a => == item.foutcode);             if (index == -1)                 graad = "";             else             {                 graad = properties.settings.default.listgraadmpu[index];                 toolbox = properties.settings.default.listtoolboxmpu[index];              }            }         if (compare == "aaux")         {              var index = properties.settings.default.listfoutcodeaaux.findindex(a => == item.foutcode);             if (index == -1)                 graad = "";             else             {                 toolbox = properties.settings.default.listtoolboxaaux[index];                 graad = properties.settings.default.listgraadaaux[index];             }           }         if (compare == "ctrl")         {              var index = properties.settings.default.listfoutcodectrl.findindex(a => == item.foutcode);             if (index == -1)                 graad = "";             else             {                 toolbox = properties.settings.default.listtoolboxactrl[index];                 graad = properties.settings.default.listgraadctrl[index];             }         }         string cat = convert.tostring(item.category);          if (cat == null)             cat = "onbeschikbaar";         try         {             datatreinfouten.add(new foutenmetnaam { datum = item.datum, foutcode = item.foutcode, module = modnaam[0].toupper(), file = modnaam[1].toupper(), name = item.name, omschrijving = item.omschrijving, time = item.time, graad = graad, foutid = item.foutid, toolbox = toolbox, category = cat.toupper()});         }         catch (exception ex)         {             xceed.wpf.toolkit.messagebox.show(ex.message);          }      } } 

the list used populate datagrid, class used list "datatreinfouten":

class foutenmetnaam     {          public datetime datum { get; set; }         public timespan time { get; set; }         public string foutcode { get; set; }         public string omschrijving { get; set; }         public string module { get; set; }         public string name { get; set; }         public int foutid { get; set; }         public string graad { get; set; }         public string file { get; set; }         public list<extrainfo> listinforondfout { get; set; }         public bool ismanueel { get; set; }         public string toolbox { get; set; }         public string category { get; set; }      } 

but can't state of how far query already. means can't update progress bar current state , because database can contain on 30.000.000 results quite needed.

edit:

i added entity data model generated sql database "events". code use this:

private eventsentities eventsentities = new eventsentities(); 

any or pointing in right direction appreciated!


Comments

Popular posts from this blog

javascript - Laravel datatable invalid JSON response -

java - Exception in thread "main" org.springframework.context.ApplicationContextException: Unable to start embedded container; -

sql server 2008 - My Sql Code Get An Error Of Msg 245, Level 16, State 1, Line 1 Conversion failed when converting the varchar value '8:45 AM' to data type int -