Data hosted with ♥ by Pastebin.com - Download Raw - See Original
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Web;
  5. using System.Web.UI;
  6. using System.Web.UI.WebControls;
  7. using MySql.Data.MySqlClient;
  8.  
  9. public partial class logon : System.Web.UI.Page
  10. {
  11.     protected void Page_Load(object sender, EventArgs e)
  12.     {
  13.  
  14.     }
  15.     protected void btlogon_Click(object sender, EventArgs e)
  16.     {
  17.         string conexao = "Server=LocalHost;Database=StoneHenge;Uid=root;Pwd='';Connect Timeout=30";
  18.         MySqlConnection conn = new MySqlConnection(conexao);
  19.         string comando = "select * from usuario where nome='" + nome.Text + "' and senha='" + senha.Text + "'";
  20.         MySqlCommand cmd = new MySqlCommand(comando,conn);
  21.         conn.Open();
  22.         MySqlDataReader dr = cmd.ExecuteReader();
  23.         if (dr.HasRows)
  24.         {
  25.             Response.Redirect("Default.aspx");
  26.         }
  27.         else {
  28.             mensagem.Text = "Senha ou usuario errado!";
  29.             //mensagem.Text = "rows "+dr.RecordsAffected.ToString();
  30.         }
  31.  
  32.  
  33.     }
  34. }