Goran Bibic

Goran Bibic

  • 482
  • 2.9k
  • 197.9k

Conect manualy from MS sql to datagrid?

Apr 19 2018 1:12 PM
I need to conect line 8 and statement from line 13 to end
 
  1. private void trenutne_zalihe2()  
  2.         {  
  3.             using (SqlConnection openCon = new SqlConnection(cs))  
  4.   
  5.             {  
  6.   
  7.   
  8.                 string saveStaff = "Select id as 'id', roba as 'Naziv artikla', kolicina as 'Kolicina' from mp_faktura_roba";  
  9.   
  10.                 using (SqlDataAdapter querySaveStaff = new SqlDataAdapter(saveStaff, cs))  
  11.   
  12.                 {  
  13.                     DataTable dt = new DataTable();  
  14.                     querySaveStaff.Fill(dt);  
  15.                     trenutnazalihadataGridView.DataSource = dt;  
  16.                     trenutnazalihadataGridView.SelectionMode = DataGridViewSelectionMode.FullRowSelect;  
  17.                     trenutnazalihadataGridView.Columns["id"].Visible = false;    
  18.                     trenutnazalihadataGridView.Columns["redni_broj"].FillWeight = 100;    
  19.                     trenutnazalihadataGridView.Columns["naziv_artikla"].FillWeight = 571;    
  20.                   
  21.   
  22.                     trenutnazalihadataGridView.Update();  
  23.                     trenutnazalihadataGridView.Refresh();  
  24.                 }  
  25.   
  26.             }  
  27.   
  28.         } 
 

Answers (3)