Nabil,
If all you need is one value from your query, then the
SqlCommand.ExecuteScalar() method is what you want to use.
Ex)
object result = new SqlCommand("SELECT [USER] FROM USERTABLE WHERE [USER] =
'" + someUser + "' AND [PASSWORD] = '" + somePassword +
"'","SomeConnectionString").ExecuteScalar();
if(result==DBNull)
throw new ApplicationException("Unknown User or Bad Password");
else
session("sessUserId") = (string)result;
Hope this helps. Obviously, you will need to change it around a bit so that
the command string has param placeholders rather than building the string
inline.
Happy Coding!
Wadih Pazos
Software Architect
Solutions@MBA
www.satmba.com www.PaperSave.com
"nabil m" wrote:
hi i am using vs.net with csharp -
i am trying to create a simple log in form
user id
password
on submit i run a param query to check if the userid and password exist if
yes i
would like to store to the contactusername in a session and rediret the user
to another page -
q: how do i check if the param select query returned a record and how do i
access the userid from my sql query to store it in a session("sessUserId")
thx