Hello,
I'm trying to crate a login form that basically logs users in..
Now, I have created the database, and queried the table to see if the user exists.. But how do you check if the query returns whether it is or not? E.g. in PHP you'd use like..
<?php
if(mysql_affected_rows() == 1)
{
}
?>
here is my code..
private void loginBUTTON_Click(object sender, EventArgs e)
{
string connection = @"Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\program.mdf;Integrated Security=True;User Instance=True";
SqlConnection connect = new SqlConnection(connection);
try
{
connect.Open();
n.setEmail(emailInput.Text);
n.setPassword(passwordInput.Text);
}
catch (Exception ex)
{
MessageBox.Show("We were unable to connect to the rquired database!" + ex);
}
try
{
string login_query = ("SELECT * FROM students WHERE email='Phillip'");
SqlCommand login = new SqlCommand(login_query, connect);
}
catch (Exception login)
{
MessageBox.Show("Unable to login" + login);
}
}