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...

Operator '>' cannot be applied to operands of type 'System.Data.DataColumn' and 'int'.

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)



my quess is Expr1Column is the name of a function, if that is correct then you need to add the parentheses

if (LogInfo.Expr1Column() > 0)

Hello Ancient Dragon - thank you for your reply. Expr1Column is a "property". It's basically the column name for the query below (typed dataset). I am very new to .net so I may be wrong at explaining things....hope you understand what I'm trying to say:

select count(*) as expr1
from tblPeople
where userid = @UserID
and passowrd = @Password.

It's basically the column name for the query below (typed dataset).

One thing I know for sure is that I'm not smart enough to use typed datasets. They've given me so much trouble that I'm more productive when I write the underlying code for them manually. :rolleyes:

But! The problem is that Expr1Column evaluates to a DataColumn object and it's not compatible with int. I can't really figure out why you're tryin' to compare a column with an integer, the only thing I can think of is that the count is the name of the column and you're tryin' to see if it's bigger than 0. If that's how it is then this'll work.

int result = Convert.ToInt32(LogInfo.Expr1Column.ColumnName);

if (result > 0)

I can't begin to imagine why you would want to do somethin' like that though. :p

Your query will evaluate to a 1 or a 0 into Expr1 but it does not return an integer it returns a table which is assigned to your LogInfo object.
That table will (i guess) contain the user name and password.
I suggest that you comment out the code causing the problem and debug to the line

Criteria.tblPeopleDataTable LogInfo = LoginAdapter.GetDataBy(UserID, Password);

Have a look at your LogInfo object in the watch window and let us know what it contains.

This article has been dead for over six months. Start a new discussion instead.