Basically I'm using LINQ to connect to a database(LoginDB) and the table (Korisnici) and see if there are entries in the username and password column that fit the entries of the Login1 Login Control.
The Error message is : Cannot implicitly convert type 'string' to 'bool'
Cannot implicitly convert type 'string' to 'bool' Operator '==' cannot be applied to operands of type 'System.Linq.IQueryable<LogInLINQ.Korisnici>' and 'string'
Operator '==' cannot be applied to operands of type 'System.Linq.IQueryable<LogInLINQ.Korisnici>' and 'string'
thanks for you help!!
using System;
using System.Collections.Generic;
using System.Data.Linq;
using System.Configuration;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Xml.Linq;
namespace LogInLINQ
{
public partial class logIn : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void Login1_Authenticate(object sender, AuthenticateEventArgs e)
{
TabelaLINQDataContext db = new TabelaLINQDataContext();
var query = from korisnik in db.Korisnicis where korisnik.username = (string)Login1.UserName select korisnik;
var query1 = from korisnik in db.Korisnicis where korisnik.password = Login1.Password.ToString() select korisnik;
if ((query == Login1.UserName) && (query1 == Login1.Password))
{
Response.Redirect("Default.aspx");
}
else lblerror.Text = "You entered invalid username/password";
}
protected void LinkButton1_Click(object sender, EventArgs e)
{
Response.Redirect("signUp.aspx");
}
}
}