Guys hi i need some help here though i fixed the connection with the sql server i tries to see if its correct and look first at the code and i explain m prob:
private void lgnBtn_Click(object sender, EventArgs e)
{
SqlConnection lgnConnection = new SqlConnection();
lgnConnection.ConnectionString="Data Source=.\\SQLEXPRESS;"+"AttachDbFilename=C:\\Users\\ryudo\\Desktop\\workspace\\sql_goldshop_project\\Project1\\Goldshop_Tax\\Goldshop_Tax\\gold_tax.mdf;"+"Integrated Security=True;"+"User Instance=True";
lgnConnection.Open();
SqlCommand cmd = new SqlCommand("SELECT username,password FROM users WHERE username='" + textBox1.Text + "' and password='" + maskedTextBox1.Text + "'", lgnConnection);
SqlDataReader dr;
dr = cmd.ExecuteReader();
while (dr.Read())
{
if (dr["username"].ToString() == textBox1.Text && dr["password"].ToString() == maskedTextBox1.Text)
{
[B]Close();[/B]
}
else
{
[B] Close();[/B]
}
}
dr.Close();
lgnConnection.Close();
i m tryin to make a login form but i tries when the username and password on my table users are the same with the one the user insert the form t close , but if i delete the close() under the else condition doesnt close it need it why havent i done sth correct ?? if u have any questions ask me i m new in c# and sql to thanks a lot!!