Hi i am tring to develope a login screen. In a windows form aplication. This is what i got:
private void button1_Click(object sender, EventArgs e)
{
if ((textBox1.Text == "") || (textBox2.Text == ""))
{
MessageBox.Show("Bu alanları boş bırakamazsınız.", "Chat Giriş", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
SqlConnection conn = new SqlConnection();
conn.ConnectionString = "Server=CAGDAS-LAPTOP;Database=chat;Trusted_Connection=true;";
conn.Open();
DataSet ds = new DataSet();
SqlDataAdapter sda = new SqlDataAdapter("select * from Kullanici WHERE kul_adi='" + textBox1.Text + "' AND sifre='" + textBox2.Text + "'", conn);
sda.Fill(ds);
if (ds.Tables.Count == 0)
{
MessageBox.Show("Geçersiz Kullanıcı.", "Chat Giriş", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
else if(ds.Tables.Count == 1)
{
MessageBox.Show("Hoşgeldiniz.", "Chat Giriş", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
by the way i am using Ms sql and logged as windows authentication. I am not sure did i write my connection string right. But when i run the program doesnt matter what i write, unless if i fill the both textbox i get "hosgeldiniz"(welcome) message. What is the problem? What am i doing wrong? For your information: kullanici is user geçersiz kullanici means wrong login info hosgeldiniz means welcome in my language.