Advertisement
Guest User

Untitled

a guest
Mar 17th, 2019
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.35 KB | None | 0 0
  1. protected void GridView1_RowUpdating(object sender, GridViewUpdateEventArgs e)
  2. {
  3. GridViewRow row = GridView1.SelectedRow;
  4. string Username = row.Cells[3].Text;
  5. string Password = row.Cells[4].Text;
  6. string Email = row.Cells[5].Text;
  7. string ID_Inscricao = row.Cells[1].Text;
  8. SqlConnection sqlConn = new SqlConnection(
  9. ConfigurationManager.ConnectionStrings["FormacaoConnectionString"].ToString());
  10. SqlCommand sqlComm = new SqlCommand();
  11.  
  12. sqlComm = sqlConn.CreateCommand();
  13. sqlComm.Parameters.Add("@Username", SqlDbType.Text);
  14. sqlComm.Parameters.Add("@Password", SqlDbType.Text);
  15. sqlComm.Parameters.Add("@Email", SqlDbType.Text);
  16. sqlComm.Parameters.Add("@ID_Inscricao", SqlDbType.Text);
  17.  
  18. sqlComm.Parameters["@Username"].Value = Username;
  19. sqlComm.Parameters["@Password"].Value = Password;
  20. sqlComm.Parameters["@Email"].Value = Email;
  21. sqlComm.Parameters["@ID_Inscricao"].Value = ID_Inscricao;
  22. string sql = "INSERT INTO Utilizadores " +
  23. "(Username, Password, Email,ID_Inscricao) " +
  24. "VALUES (@Username, @Password, @Email, @ID_Inscricao)";
  25. sqlComm.CommandText = sql;
  26. sqlConn.Open();
  27. sqlComm.ExecuteNonQuery();
  28. sqlConn.Close();
  29. }
  30.  
  31. sqlComm.Parameters["@Username"].Value = Username;
  32.  
  33. sqlComm.Parameters.Add("@Username", SqlDbType.Text);
  34.  
  35. string Username = row.Cells[3].Text;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement