.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Home >> Code Snippets >> ADO.NET >> Post New Resource Bookmark and Share   

 Subscribe to Code Snippets

Login Page in C#

Posted By:Shashi Ray       Posted Date: September 02, 2008    Points: 10    Category: ADO.NET    URL: http://www.dotnetspark.com  

This sample code show how to validate user login page using database in ADO.Net

This sample example is in C#. You can paste this code in your login Button click event



SqlCommand cmd=new SqlCommand ("select count(*) from login where user = @u and pass= @p, con);

cmd.Parameters.Add("@u", SqlDbType.Varchar, 10).Value=TextLogin.Text.Trim();

cmd.Parameters.Add("@p", SqlDbType.Varchar,10).Value=TextPwd.Text.Trim();

int count=(int)cmd.ExecuteScalar();

if(count >0)






LabelError.Text="Invalid User Name or Password";



Further Readings:


No response found. Be the first to respond this post

Post Comment

You must Sign In To post reply
Find More code samples in C#, ASP.Net, Vb.Net and more Here

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend