Goran Bibic

Goran Bibic

  • 453
  • 2.9k
  • 181k

Define variable from count sql command

Apr 5 2018 2:38 PM
Need to define variable count i=count
 
Becose I need to auto create number of buttons from counter
 
  1. SqlCommand cmd = new SqlCommand();  
  2.             cmd.CommandText = "SELECT COUNT(*) FROM roba_usluge";  
  3.             Int32 count = (Int32)cmd.ExecuteScalar();  
  4.   
  5.             int top = 50;  
  6.             int left = 50;  
  7.             for (int i = 0; i = count.ToString(); i++)  
  8.             {  
  9.                 Button button = new Button();  
  10.                 button.Left = left;  
  11.                 button.Top = top;  
  12.                 button.Text = (i + 1).ToString();  
  13.                 this.Controls.Add(button);  
  14.                 top += button.Height + 2;  
  15.             } 
 

Answers (9)