0% found this document useful (0 votes)
5 views2 pages

Page

The document is a C# ASP.NET web page code that handles user login functionality. It establishes a connection to a database and checks if the provided username and password match any existing records using a stored procedure. If the credentials are valid, it redirects the user to another page; otherwise, it displays an error message.

Uploaded by

m0nst3rs737
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views2 pages

Page

The document is a C# ASP.NET web page code that handles user login functionality. It establishes a connection to a database and checks if the provided username and password match any existing records using a stored procedure. If the credentials are valid, it redirects the user to another page; otherwise, it displays an error message.

Uploaded by

m0nst3rs737
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

using System;

using System.Collections.Generic;
using System.Configuration;
using System.Data.SqlClient;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Data.SqlClient;

public partial class Sayfa2BK : System.Web.UI.Page


{
public string baglantiMetni =
ConfigurationManager.ConnectionStrings["veritabaniminAdresi"].ToString();

protected void Page_Load(object sender, EventArgs e)


{
if(!IsPostBack)
{
try
{
txtSifre.TextMode = TextBoxMode.Password;
lblKullaniciAdi.Text = "Kullanıcı Adı:";
lblSifre.Text = "Sifre:";
butGiris.Text = "Oturum Aç";

}
catch
{
Response.Redirect("Sayfa1BK.aspx");

protected void butGiris_Click(object sender, EventArgs e)


{

if(!(String.IsNullOrWhiteSpace(txtSifre.Text) ||
String.IsNullOrWhiteSpace(txtKullAdi.Text)))
{
SqlConnection sqlConnection = new SqlConnection(baglantiMetni);
SqlCommand sqlKomutuKullanicilar = new SqlCommand()
{
Connection = sqlConnection,
CommandType = CommandType.StoredProcedure,
CommandText = "SP_KullaniciVarMiBK"
};

SqlParameter pKAdi = new SqlParameter("@pKAdi", SqlDbType.VarChar);


SqlParameter pSifre = new SqlParameter("@pSifre",
SqlDbType.VarChar);

sqlKomutuKullanicilar.Parameters.Add(pKAdi);
sqlKomutuKullanicilar.Parameters.Add(pSifre);

pKAdi.Value = txtKullAdi.Text;
pSifre.Value = txtSifre.Text;

sqlConnection.Open();
byte gelenVeri =
Convert.ToByte(sqlKomutuKullanicilar.ExecuteScalar());
sqlConnection.Close();

if (gelenVeri != 0)
{
Session["kAdi"] = txtKullAdi.Text;
Response.Redirect("Sayfa3BK.aspx");
}
else
{
lblMesaj.Text = "kAdi veya sifre yanlış tekrar dene.";
}
}
}
}

You might also like