Hello Everyone,
I'm creating a web site application through VWD 2008 express edition.
what i've done so far:
1- created a database MDF file in App_data
2- Created a dataset in root directory
3- thrown some tables from my database into that dataset
4- created a query on the users tableAdapter to getDataByUsername
this getDataByUsername(@username) query text is :
Code:
SELECT user_id, password, email, creationdate, lastaccess, dept_id, fname, lname, status FROM users WHERE (username = @username)
ofcourse, the type of the query is an SQL statement (SELECT which returns rows)
but should return only one row.
anyway,
what i'm trying to do in one code-behind file is this.
Code:
using eMIS.eMISDBTableAdapters;
///////////////////////
usersTableAdapter userAD = new usersTableAdapter();
////////////////////////////////
public static void populateUserInfo(string user)
{
HttpContext.Current.Session.Add("userid",userAD.GetDataByUsername(user).user_idColumn..ToString());
HttpContext.Current.Session.Add("username",user);
}
the problem i'm facing is with this code
Code:
userAD.GetDataByUsername(user).user_idColumn..ToString()
i think the the adapter thinks the query is returning more than one row so i can't just use the .user_idColumn to get the value of it.
in other scenarios i've used userAD.checkUser(user, pass); to return only one value (not only one row) which then returned an integer = 1 if there's a user with that username and password in the database.
if someone could help me with this i'll really appreciate it.
Regards,
Mohannad