Дополнительная информация: неверный синтаксис рядом с ', '.
SqlConnection conn = new SqlConnection(@"server=DELL-PC\SQLEXPRESS;Database=WinApp;Integrated Security = true"); SqlCommand cmd = new SqlCommand("select count(*) from LoginInfo where Username = @uname, password = @pwd",conn); cmd.Parameters.Add(new SqlParameter("@uname", lblunametxt.Text)); cmd.Parameters.Add(new SqlParameter("@pwd", lblpwdtxt.Text)); conn.Open(); int noOfRowsAffected = (int)cmd.ExecuteScalar(); conn.Close(); if(noOfRowsAffected > 0) { MDIParent md = new MDIParent(); md.Show(); this.Hide(); } else { Console.Write(" invalid credentials"); }
Что я уже пробовал:
SqlConnection conn = new SqlConnection(@"server=DELL-PC\SQLEXPRESS;Database=WinApp;Integrated Security = true"); SqlCommand cmd = new SqlCommand("select count(*) from LoginInfo where Username = @uname, password = @pwd",conn); cmd.Parameters.Add(new SqlParameter("@uname", lblunametxt.Text)); cmd.Parameters.Add(new SqlParameter("@pwd", lblpwdtxt.Text)); conn.Open(); int noOfRowsAffected = (int)cmd.ExecuteScalar(); conn.Close(); if(noOfRowsAffected > 0) { MDIParent md = new MDIParent(); md.Show(); this.Hide(); } else { Console.Write(" invalid credentials"); }