Kodlarımızı aşağıdaki gibi yazıyyoruz.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using MySql.Data.MySqlClient;
public partial class _Default : System.Web.UI.Page
{
protected void getir(string git)
{
string MyConString = "SERVER=localhost;" +
"DATABASE=deneme102;" +
"UID=root;" +
"PASSWORD=;";
MySqlConnection connection = new MySqlConnection(MyConString);
MySqlCommand command = connection.CreateCommand();
MySqlDataReader Reader;
command.CommandText ="SELECT adi,parola " + "FROM bilgiler " +
"WHERE adi = '" + TextBox1.Text + "' AND parola = '" + TextBox2.Text + "'";
connection.Open();
Reader = command.ExecuteReader();
Reader.Read();
if (Reader.HasRows)
{
Response.Write("Başarılı giriş");
}
else
{
Response.Write("Hatalı giriş");
}
Reader.Close();
connection.Close();
}
protected void Button1_Click(object sender, EventArgs e)
{
getir("git");
}
protected void Page_Load(object sender, EventArgs e)
{
}
}