473,395 Members | 1,624 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

simple login form

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
Nov 16 '05 #1
1 8828
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

Nov 16 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: calaha | last post by:
Hi all, I have been working with this since last night, and can't quite figure out why it's not working. I have a simple login box form that is set to be my startup form in my Access app (upon...
1
by: Tuan Nguyen | last post by:
Hello all, I have a website about 10 pages. One of them is login page. I am using Simple Form Authentication with database to allow user login and logout. My problem is whenever my website is...
0
by: Dam6 | last post by:
Hello, Having a bit of trouble with a simple login page etc using an access db. (Using DW 2004 and databases from Sean R. Nicholson) I've created a virtual application, added the dw ctrls and...
1
by: carmstrong | last post by:
I'm new to PHP and I'm trying to write up a simple PHP login page script to authenticate users from a flat file. I've managed to make most of it work, except that it only accepts the last user on...
2
by: Sasquatch | last post by:
I'm having trouble creating a simple login page using the asp:login control. I followed some instructions in a WROX book, "Beginning ASP.NET 2.0," and the instructions are very straight forward,...
5
markmcgookin
by: markmcgookin | last post by:
Hi Folks, Happy new year to all! I have two questions here, which I hope will be relatively simple you you guys to answer! 1) Is it possible to stick a line or two of code in a form somewhere...
1
by: bobmct | last post by:
Again: struggling to convert old-style HTML to html using css. I am trying to create a rectangular box divided into approx three vertical sections. The top section contains an image I would like...
5
by: olaamussah | last post by:
Hi, i just started learning perl which i would use for my uni. project unfortunately. Well, this is a simple user login page i tried to create but i cant get it to work. Can someone please check this...
4
by: ldpfrog | last post by:
This is my first tutorial, so if there are any mistakes please forgive me =). This will show you a very simple way to read your Login information from an outside text file. What you need: 1....
1
by: carl2k2 | last post by:
Ok First I have a very simple way of entering data into a form and saving that into a text file, I made two text files for username(text1) and password(text2), I would like to make a simple login...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.