i am creating a login screen in vb.net using csharp.
when user click login button i want to redirect to another page if user enter wrong username and password, message shows please enter valid user name and password.
this is window application
Loading

Kunal VaishyaRank #990 · 2K reputationPosted Jul 2, 2012, 1:47 AM EDT
i am sending you a code download it
Jaganathan BantheswaranRank #170 · 14.1K reputationPosted Jul 2, 2012, 1:56 AM EDT
I am not clear whether you are using VB.Net or C#.Net.
Here is the Video
Satyapriya NayakRank #47 · 31.5K reputationPosted Jul 2, 2012, 2:44 AM EDT
Try this...
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 Login_page_Msaccess
{
public partial class Form1 : Form
{
string ConnectionString = System.Configuration.ConfigurationSettings.AppSettings["dsn"];
OleDbCommand com;
string str;
object obj = null;
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)
{
Form2 f1 = new Form2();
f1.Show();
this.Hide();
}
else
{
lb1.Text = "Invalid user name and password";
}
con.Close();
}
}
}
Thanks
If this post helps you mark it as answer