Advertisement
Guest User

Untitled

a guest
Jan 25th, 2020
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.34 KB | None | 0 0
  1. public void SacuvajAsisUBazu()
  2. {
  3.  
  4. using (SqlConnection conn = new SqlConnection(Data.CONNECTION_STRING))
  5. {
  6. conn.Open();
  7. SqlCommand command = conn.CreateCommand();
  8. command.CommandText = @"insert into Asistent(Ime, KorisnickoIme, Prezime, TipZaposlenog,Lozinka,Email,Profesor, Active) values
  9. (@Ime, @KorisnickoIme,@Prezime, @TipZaposlenog, @Lozinka, @Email, @Profesor, @Active)";
  10. command.Parameters.Add(new SqlParameter("Ime", this.Ime));
  11. command.Parameters.Add(new SqlParameter("KorisnickoIme", this.KorisnickoIme));
  12. command.Parameters.Add(new SqlParameter("Prezime", this.Prezime));
  13. command.Parameters.Add(new SqlParameter("TipZaposlenog", this.TipZaposlenog));
  14. command.Parameters.Add(new SqlParameter("Lozinka", this.Lozinka));
  15. command.Parameters.Add(new SqlParameter("Email", this.Email));
  16. command.Parameters.Add(new SqlParameter("Profesor", this.Prof.KorisnickoIme));
  17.  
  18. command.Parameters.Add(new SqlParameter("Active", this.Active));
  19.  
  20. command.ExecuteScalar();
  21.  
  22. }
  23.  
  24. }
  25.  
  26. public void UpdateAsis()
  27. {
  28. using (SqlConnection conn = new SqlConnection(Data.CONNECTION_STRING))
  29. {
  30. conn.Open();
  31.  
  32. SqlCommand command = conn.CreateCommand();
  33. command.CommandText = @"update Asistent set Ime =@Ime, Prezime =@Prezime,Lozinka =@Lozinka, Email =@Email, Profesor =@Profesor, Active =@Active
  34. where KorisnickoIme = @KorisnickoIme";
  35. command.Parameters.Add(new SqlParameter("Ime", this.Ime));
  36. command.Parameters.Add(new SqlParameter("Prezime", this.Prezime));
  37. command.Parameters.Add(new SqlParameter("Lozinka", this.Lozinka));
  38.  
  39. command.Parameters.Add(new SqlParameter("Email", this.Email));
  40. command.Parameters.Add(new SqlParameter("Active", this.Active));
  41. command.Parameters.Add(new SqlParameter("Profesor", this.Prof.KorisnickoIme));
  42.  
  43. command.Parameters.Add(new SqlParameter("KorisnickoIme", this.KorisnickoIme));
  44.  
  45. command.ExecuteNonQuery();
  46.  
  47.  
  48. }
  49. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement