Guest User

Untitled

a guest
Apr 19th, 2018
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.40 KB | None | 0 0
  1.         <tr>
  2.                 <td >
  3.                     Escolha um perfil
  4.                 </td>
  5.                 <td>
  6.                     <asp:DropDownList ID="mostraUsuarios" runat="server" >
  7.                     </asp:DropDownList>
  8.                     <asp:Button runat="server" Text="Carregar perfil" OnClick="carregaPerfilUsuario"/>
  9.                 </td>
  10.             </tr>
  11.  
  12.  
  13.  
  14.  
  15.  
  16.  
  17. protected void carregaPerfilUsuario(object sender, EventArgs e)
  18.         {
  19.  
  20.             String nome = mostraUsuarios.SelectedItem.Value;    // pega valor do dropDownList
  21.            
  22.             SqlConnection conn = new SqlConnection("Data Source=sqlserver01.webint.com.br;Initial Catalog=webint;Persist Security Info=True;User ID=webint;Password=igor1990");
  23.             SqlDataReader reader = null;
  24.             SqlCommand cmm = new SqlCommand("select * from tb_usuarios where nome = '" +nome+"'", conn);
  25.             try
  26.             {
  27.                 conn.Open();
  28.                 reader = cmm.ExecuteReader();
  29.                 editar_nome.Text = reader.GetString(2);
  30.                 editar_email.Text = reader.GetString(3);
  31.                 editar_telefone.Text = reader.GetString(5);
  32.             }
  33.             catch (Exception ex)
  34.             {
  35.                 // throw ex;
  36.             }
  37.             finally
  38.             {
  39.                 conn.Close();
  40.                 conn.Dispose();
  41.             }
  42.            
  43.         }
Add Comment
Please, Sign In to add comment