operator error

Please support our C# advertiser: Intel Parallel Studio Home
Reply

Join Date: Sep 2006
Posts: 9
Reputation: kathy78 is an unknown quantity at this point 
Solved Threads: 0
kathy78 kathy78 is offline Offline
Newbie Poster

operator error

 
0
  #1
Oct 9th, 2006
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");
}

}

}
}
}
Reply With Quote Quick reply to this message  
Join Date: Aug 2005
Posts: 15,485
Reputation: Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute 
Solved Threads: 1478
Team Colleague
Featured Poster
Ancient Dragon's Avatar
Ancient Dragon Ancient Dragon is offline Offline
Still Learning

Re: operator error

 
0
  #2
Oct 9th, 2006
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)
Reply With Quote Quick reply to this message  
Join Date: Sep 2006
Posts: 9
Reputation: kathy78 is an unknown quantity at this point 
Solved Threads: 0
kathy78 kathy78 is offline Offline
Newbie Poster

Re: operator error

 
0
  #3
Oct 9th, 2006
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.
Reply With Quote Quick reply to this message  
Join Date: Sep 2006
Posts: 90
Reputation: Inanna is on a distinguished road 
Solved Threads: 6
Inanna's Avatar
Inanna Inanna is offline Offline
Junior Poster in Training

Re: operator error

 
0
  #4
Oct 9th, 2006
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.
  1. int result = Convert.ToInt32(LogInfo.Expr1Column.ColumnName);
  2.  
  3. if (result > 0)
I can't begin to imagine why you would want to do somethin' like that though. :p
Last edited by Inanna; Oct 9th, 2006 at 4:48 pm.
Reply With Quote Quick reply to this message  
Join Date: Oct 2006
Posts: 16
Reputation: peterbyrne is an unknown quantity at this point 
Solved Threads: 1
peterbyrne peterbyrne is offline Offline
Newbie Poster

Re: operator error

 
0
  #5
Oct 9th, 2006
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.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC