Goran Bibic

Goran Bibic

  • 475
  • 2.9k
  • 200.9k

Get value with reader from another form c#

May 24 2018 3:00 AM
Need string to label
 
  1. InitializeComponent();    
  2. korisnickoImeLabel.Text = getKorisnickoIme();   
 
What I wrong?
Query is ok
 
  1. private String getKorisnickoIme()    
  2.         {    
  3.             SqlConnection myConnection = new SqlConnection(cs);    
  4.             String value = "SELECT ime_prezime FROM osobe_korisnici WHERE id='" + korisnikId + "'";    
  5.             SqlCommand cmd = new SqlCommand(value, myConnection);    
  6.             myConnection.Open();    
  7.             SqlDataReader rdr = cmd.ExecuteReader();                    
  8.             return value;    
  9.                 
  10.         }   
 Result in label is
 SELECT ime_prezime FROM osobe_korisnici WHERE id='10'
 
 
id is 10, but I need to write in label name and surname for user (ime_prezime)

Answers (3)