Stylus STYLUS

Stylus STYLUS

  • NA
  • 17
  • 1.2k

Get user name from one form to another c#

May 23 2018 4:11 AM
Get user name from one form to another
 
access rights
 
I have error in  line 28
 
{"Invalid column name 'a'."}   
 
a is username and pasword
 
  1. private static int korisnikId;  
  2. private static int korisnickaGrupa;  
  3. private string korisnickoIme;  
  4.   
  5. public void findsUserName()  
  6.         {  
  7.             SqlConnection myConnection = new SqlConnection(cs);  
  8.             String command = "SELECT ime_prezime FROM osobe_korisnici  where id = \"" + korisnikId + "\"";  
  9.         
  10.             SqlCommand myCommand = new SqlCommand(command, myConnection);  
  11.   
  12.   
  13.             myCommand.Connection.Open();  
  14.             this.korisnickoIme = myCommand.ExecuteScalar().ToString();  
  15.         }  
  16.   
  17. private void prijava()  
  18.         if (korisnikId > 0)  
  19.             {  
  20.                 command = "SELECT osobe_korisnici.lozinka FROM osobe_korisnici where osobe_korisnici.id = " + korisnikId;  
  21.                 SqlCommand myCommand2 = new SqlCommand(command, myConnection);  
  22.                 String lozinka = myCommand2.ExecuteScalar().ToString();  
  23.                 if (lozinka == lozinkaTextBox.Text)  
  24.                 {  
  25.                     command = "SELECT korisnik_grupa.redni_broj FROM korisnik_grupa where korisnik_grupa.broj_grupe = \"" + korisnikId + "\"";  
  26.                     
  27.                     SqlCommand myCommand3 = new SqlCommand(command, myConnection);  
  28.                     korisnickaGrupa = Int32.Parse(myCommand3.ExecuteScalar().ToString());  
  29.                      
  30.                     if (korisnickaGrupa == 1)  
  31.                         {  
  32.                         findsUserName();  
  33.                         DialogResult = DialogResult.OK;  
  34.                     }  
  35.                     else  
  36.                     {  
  37.                         errorLabel.Text = "You dont have acces for this app";  
  38.                     }  
  39.                 }  
  40.                 else  
  41.                 {  
  42.                     errorLabel.Text = "Wrong password";  
  43.                 }  
  44.             }  
  45.             else  
  46.             {  
  47.                 errorLabel.Text = "Wrong user name";  
  48.             }  
  49.   
  50.   
  51.         } 
 

Answers (2)