How to do login page by pressing enter button from keyboard [Resolved]

Posted by Jitenkumar under C# on 8/18/2013 | Points: 10 | Views : 1265 | Status : [Member] | Replies : 1
How to do login page by pressing enter button from keyboard




Responses

Posted by: Satyapriyanayak on: 8/18/2013 [Member] [MVP] Silver | Points: 50

Up
0
Down

Resolved
You donot need to click mouse on login button rather enter button from keyboard wright if it is so then  


using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Data.OleDb;
namespace
{
public partial class Form1 : Form
{
string ConnectionString = System.Configuration.ConfigurationSettings.AppSettings["dsn"];
OleDbCommand com;
string str;
object obj ;

public Form1()
{
InitializeComponent();
}

private void btn_login_Click(object sender, EventArgs e)
{

OleDbConnection con = new OleDbConnection(ConnectionString);
con.Open();
str = "select count(*) from login where UserName=@UserName and Password =@Password";
com = new OleDbCommand(str, con);
com.CommandType = CommandType.Text;
com.Parameters.AddWithValue("@UserName", TextBox_user_name.Text);
com.Parameters.AddWithValue("@Password", TextBox_password.Text);
obj = com.ExecuteScalar();
if ((int)(obj) != 0)
{
lb1.Text = "WELLCOME :: " + TextBox_user_name.Text;
}
else
{
lb1.Text = "invalid user name and password";
}
con.Close();
}

private void Form1_Load(object sender, EventArgs e)
{
this.AcceptButton = btn_login;

}

}
}


If this post helps you mark it as answer
Thanks

Jitenkumar, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response