Merhaba arkadaşlar…
Hepimizin ortak bi derdine çözüm olmak ve yeni açtığım Blog sayfamda yararlı olacağına inandığım için .NET C Sharp’da Login sayfası oluşturmaktan bahsedeceğim. Bütün projelerimiz için ilk adım ….
private void btn_login_Click(object sender, EventArgs e)
{
try
{
SqlConnection myConnection = new SqlConnection(“Data Source=.;Initial Catalog=Test1;Integrated Security=True”); myConnection.Open();
SqlCommand myCommand = new SqlCommand(“SELECT Owner_Name,Password FROM Owner WHERE Owner_Name = ‘” + txt_username.Text + “‘ AND Password = ‘” + txt_password.Text + “‘”, myConnection);
SqlDataReader myReader = myCommand.ExecuteReader();
if (txt_username.Text != “” && txt_password.Text != “”)
{
if (myReader.Read())
{
Main frm = new Main();
frm.ShowDialog();
this.Hide();
myConnection.Close();
}
else
{
MessageBox.Show(“Wrong User Name or Password !”, “Warning”, MessageBoxButtons.OK, MessageBoxIcon.Warning);
txt_username.Clear();
txt_password.Clear();
}
}
else
{
MessageBox.Show(“Please, Fill all neccessary fields.”, “Warning”, MessageBoxButtons.OK,MessageBoxIcon.Warning);
myConnection.Close();
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
finally
{
myConnection.Close();
Application.Exit();
}
}

[...] Login Form Yapımı June 2009 3 [...]