473,406 Members | 2,698 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,406 software developers and data experts.

login and regsitration using stored proedure

Hi i want to create login and registration button in web page, by creating a stored procedure in sql server, just help me how to create those procedure and how can i give parameters to the login button

thank you
raghu
Nov 28 '07 #1
4 1142
dip_developer
648 Expert 512MB
Hi i want to create login and registration button in web page, by creating a stored procedure in sql server, just help me how to create those procedure and how can i give parameters to the login button

thank you
raghu
a simple stored procedure will look like..........

Expand|Select|Wrap|Line Numbers
  1.  
  2. CREATE PROCEDURE sp_UserValidation
  3. (
  4. @Username varchar(50),
  5. @UserPassword varchar(10)
  6. AS
  7. IF EXISTS (SELECT UserName FROM tblLogIn WHERE UserName=@Username and UserPassword=@UserPassword)
  8. BEGIN
  9. return 1
  10. END
  11. ELSE
  12. BEGIN
  13. return 0
  14. END
  15. GO
  16.  
call a function like the following to validate the user...pass the Username and Password to the function.................code is in C#......

Expand|Select|Wrap|Line Numbers
  1.  
  2. public int UserValidation(string uname,string pass)
  3. {
  4. int retVal=0;
  5. cmdTrans = new SqlCommand();
  6. cmdTrans.Connection = myConnection;
  7. cmdTrans.CommandType = CommandType.StoredProcedure;
  8. cmdTrans.CommandText="sp_UserValidation";
  9. SqlParameter param1=new SqlParameter("@Username",SqlDbType.VarChar,50);
  10. param1.Value=uname;
  11. SqlParameter param2=new SqlParameter("@UserPassword",SqlDbType.VarChar,10);
  12. param2.Value=pass;
  13. SqlParameter param3=new SqlParameter("@Return",SqlDbType.Int,4);
  14. param3.Direction=ParameterDirection.ReturnValue;
  15. cmdTrans.Parameters.Add(param1);
  16. cmdTrans.Parameters.Add(param2); 
  17. cmdTrans.Parameters.Add(param3);
  18. cmdTrans.ExecuteNonQuery();
  19. retVal = (int) param3.Value;
  20. if (!(myConnection == null)) 
  21. {
  22. myConnection.Close();
  23. }
  24. return retVal;
  25. }
if the user is valid then the function UserValidation() will return 1

hope it will help you.......
Nov 28 '07 #2
thank a lot ,I made through you code
Nov 28 '07 #3
hi dip
i created the login information in my website but if want to update the profile of paticular login member what r the process just send me sample codding

thank you in advance
Dec 5 '07 #4
kenobewan
4,871 Expert 4TB
A better stored procedure will look like..........

Expand|Select|Wrap|Line Numbers
  1.  
  2. CREATE PROCEDURE usp_UserValidation
  3. (
  4. @Username varchar(50),
  5. @UserPassword varchar(10)
  6. AS
  7. set nocount on
  8. IF EXISTS (SELECT UserName FROM tblLogIn WHERE UserName=@Username and UserPassword=@UserPassword)
  9. BEGIN
  10. return 1
  11. END
  12. ELSE
  13. BEGIN
  14. return 0
  15. END
  16. GO
  17.  
The value 1 or 0 is returned and I do not see how it is used. Also a try/catch block would be better in case of errors.

Suggest peerraghu you start writing your own code if you want to learn.
Dec 5 '07 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

6
by: josephrthomas | last post by:
hi..i am trying to make a login page and i am using access table.. when the user enters his userid and password i want to check the password from the table.. if any user with the userID that is...
0
by: sbest | last post by:
Hi all, I am trying to execute a MS-SQL 2000 stored proedure from PHP 4.2.2 and return the single row of 3 output values. I've whittled down the error messages so that I'm now mainly getting an...
8
by: Coy | last post by:
I've added the ASPNET user to my local SQL Server 2000, but I still get an unhandled exception: Login failed for user 'C594891-A\ASPNET'. This is when using a web service. A similiar ASP.NET...
19
by: Siobhan | last post by:
Hi What is the recommended way to store a user's database credentials across the pages of a web application so that each time the database is accessed the system doesn't have to ask them for their...
0
by: ShailShin | last post by:
Hi All, Developing an VB App for Login and logout tracking. In App Form there are two buttons login and logout. When user click on login the loginName, LoginTime and LoginDate get stored in...
1
by: xcelmind | last post by:
Hello Dev. Guru, I want to at this time introduce myself. I am Stanley Ojadovwa by name. I’m a freelance and a newbie in web application development. I’m currently using ASP as my application...
2
by: antonyliu2002 | last post by:
I am testing ASP.NET 2.0 Forms athentication with user credentials in SQL Server 2005. I don't want to put user credentials in web.config, so the credentials section is commented out. The...
3
JamieHowarth0
by: JamieHowarth0 | last post by:
Hi folks, Got a bit of an interesting question. I'm in the process of learning ASP.NET using Microsoft's CTP of Visual Web Studio "Orcas". Part of my classic ASP website incorporates a login...
9
by: Josh | last post by:
I run a Joomla website and am familiar with php in some but not all aspects. Currently I am trying to find some solutions related to session handling. Am I correct in saying that "login" is kept...
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.