I'm trying to construct a log in using the SqlServer which I'm not so familiar with. I don't ask for a very precise answer but more of a point in a general direction where the error may be. Should I learn more about the SqlServer to solve this problem or is the error somewhere else?
namespace Log_in
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void btnLogIn_Click(object sender, EventArgs e)
{
SqlConnection con = new SqlConnection(@"Data Source=(LocalDB)\MSSQLLocalDB;AttachDbFilename=C:\Users\Joel\Documents\Data.mdf;Integrated Security=True;Connect Timeout=30");
SqlDataAdapter sda = new SqlDataAdapter("SELECT COUNT(*) FROM Login WHERE Username='" + tbxLogIn.Text + "'AND Password ='"+tbxPassword.Text+"'", con);
DataTable dt = new DataTable();
sda.Fill(dt);
if (dt.Rows[0][0].ToString() == "1")
{
this.Hide();
Main ss = new Main();
ss.Show();
}
else
{
MessageBox.Show("Incorrect log in details.");
}
}
private void btnExit_Click(object sender, EventArgs e)
{
this.Close();
}
}
}