4
Answers

(using SQLite) DataGridView showing only three rows from my DB

Hey there.. after days of trying to solve this problem by trying some variations of my code, I'm desperate.
 
I'm trying to fill my DataGridView with SQLite database - it works.. but.. DatGridView shows me only a few rows, for whatever reason.
 
additional info:
SQLite queries work perfectly (tried in "DB Browser in SQLite")
also tried UNION/UNION ALL and cmd.ExecuteReader/cmd.ExecuteNonQuery + cmd.ExecuteReader
 
code:
  1. private void button1_Click(object sender, EventArgs e)  
  2. {  
  3. SQLiteConnection myconnection = new SQLiteConnection("Data Source=C:\\Users\\jprochazka\\Desktop\\HG DB SQLite\\hg_db07 - serverside\\hg_db06\\databaze_heinz_glas.db;Version=3");  
  4. myconnection.Open();  
  5. SQLiteCommand cmd = new SQLiteCommand();  
  6. cmd.Connection = myconnection;  
  7. cmd.CommandText = "SELECT id, nazev_tabulky, nazev_zarizeni, typ_zarizeni, vyrobce, umisteni, evidencni_cislo FROM Spotrebice UNION " +  
  8. "SELECT id, nazev_tabulky, nazev_zarizeni, typ_zarizeni, vyrobce, umisteni, evidencni_cislo FROM Stroje UNION " +  
  9. "SELECT id, nazev_tabulky, prurez, typ_kabelu, vyrobce, umisteni, evidencni_cislo FROM Prodluzovaci_Privody UNION " +  
  10. "SELECT id, nazev_tabulky, nazev, oznaceni, vnejsi_vlivy, null, ev_c FROM Prostory UNION " +  
  11. "SELECT id, nazev_tabulky, oznaceni, typ_zarizeni, vyrobce, umisteni, vyrobni_cislo FROM Rozvadece;";  
  12. using (SQLiteDataReader sdr = cmd.ExecuteReader())  
  13. {  
  14. DataTable dt = new DataTable();  
  15. dt.Load(sdr);  
  16. sdr.Close();  
  17. myconnection.Close();  
  18. dataGridView1.DataSource = dt;  
  19. }  
  20. } 
Thanks for every advice. 

Answers (4)