Please use this ..
private void button5_Click(object sender, EventArgs e)
{
string str = @"Data Source=J:\BerendinaSW\Payment20150408\Payment2015\Social.sdf;Persist Security Info=True";
SqlConnection con = new SqlConnection(str);
try{
con.Open();
}
catch(Exception ){
MessageBox.Show("cannot connect");
}
SqlCommand cm = new SqlCommand("SELECT * FROM [admin]",con);
SqlDataReader reader = null;
con.Open();
reader = cm.ExecuteReader();
con.Close();
while (reader.Read())
{
if (textBox1.Text ==(reader["username"].ToString()) && textBox2.Text == (reader["password"].ToString()))
{
label8.Visible = true;
}
else
{
label9.Visible = true;
textBox1.Text = "";
textBox2.Text = "";
}
}
}
Thanks
AARIF SHAIKH