Hello everyone,
I have the following code behind for a login page. When I compile, I am getting the following error. It won't allow me to use the operator > in the line below in red. Can someone please tell me why? Expr1 basically returns a number - either 1 (account exist) or 0 (account doesn't exist). Thanks for your help...
Error:
Operator '>' cannot be applied to operands of type 'System.Data.DataColumn' and 'int'.
Login.aspx.cs:
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using System.Web.Security;
using System.Data.SqlClient;
using System.Configuration;
using CriteriaTableAdapters;
namespace TestLogin
{
publicpartialclassWebForm1 : System.Web.UI.Page
{
protected System.Web.UI.WebControls.TextBox UserID;
protected System.Web.UI.WebControls.TextBox Password;
protected System.Web.UI.WebControls.Button cmdSubmit;
privatevoid Page_Load(object sender, System.EventArgs e)
{
}
protectedvoid cmdSubmit_Click(object sender, System.EventArgs e)
{
string UserID = string.Empty;
string Password = string.Empty;
UserID = ((TextBox)Login1.FindControl("UserID")).Text;
Password = ((TextBox)Login1.FindControl("Password")).Text;
if (Page.IsValid)
{
tblPeopleTableAdapter LoginAdapter = newtblPeopleTableAdapter();
Criteria.tblPeopleDataTable LogInfo = LoginAdapter.GetDataBy(UserID, Password);
// Redirect if we succeeded
if (LogInfo.Expr1Column > 0)
{
Response.Redirect("Default.aspx");
}
else
{
Response.Redirect("SignInError.aspx");
}
}
}
}
}