C# Tutorials and offshore development in India
    Tutorials   Resources   Forum   Reviews   Communities   Interview   Jobs   Projects   Training   Your Ad Here    
Silverlight Games | Mentor | Code Converter | Articles | Code Factory | Computer Jokes | Members | Peer Appraisal | IT Companies | Bookmarks | Polls | Revenue Sharing | Lobby | Gift Shop |


Prizes & Awards
My Profile



Active Members
TodayLast 7 Days more...






Resources » Code Snippets » ADO.NET »

Login by backend table data


Posted Date: 30 Aug 2009    Resource Type: Code Snippets    Category: ADO.NET
Author: NikhilMember Level: Silver    
Rating: 1 out of 5Points: 5



Login by backend table data...


This code shows how to login using backend table data


private void button1_Click(object sender, EventArgs e)
{
SqlConnection con = new SqlConnection();
con.ConnectionString = "data source = JBB-690AB60E108;,Initial catalog = True; Integrated Security = True";
con.Open();

SqlCommand cmd = new SqlCommand("select username,pass from loge where username=@UserName and pass=@password ", con);
cmd.Parameters.Add("@UserName", SqlDbType.VarChar, 10);
cmd.Parameters.Add("@password", SqlDbType.VarChar, 15);

cmd.Parameters["@UserName"].Value = textBox1.Text;
cmd.Parameters["@password"].Value = textBox2.Text;

if ((cmd.ExecuteReader().HasRows))
{
MessageBox.Show("Welcome");
}
else
{
MessageBox.Show("Check the UserName or Password", "Incorrect Entry", MessageBoxButtons.RetryCancel, MessageBoxIcon.Exclamation);
}
}
}
}


Thanks
Nikhil

For more details, visit www.dotnetask.blog.co.in



Responses

Author: pankaj gupta    15 Nov 2009Member Level: Silver   Points : 0
Thank you for this code. This is really working.


Feedbacks      
Popular Tags   What are tags ?   Search Tags  
Sign In to add tags.
Login by backend table data  .  

Post Feedback


This is a strictly moderated forum. Only approved messages will appear in the site. Please use 'Spell Check' in Google toolbar before you submit.
You must Sign In to post a response.
Next Resource: Save the details to backend by ADO.NET
Previous Resource: Storing values in a Oracle Database
Return to Discussion Resource Index
Post New Resource
Category: ADO.NET


Post resources and earn money!
 
More Resources



dotNet Slackers

About Us    Contact Us    Privacy Policy    Terms Of Use