
After Mentioning How you can develop a login form in VB.Net and login form in VB6 here I will describe the development of login form in C Sharp Dot Net.
Developing a window based login form in C Sharp .Net is a little different from what we have done for VB.Net and Vb6,Here you do not have built in login form so you have to design a simple login form with two text boxes, labels and command buttons.Following screen shot will show you a simple layout

Login Form
Specifying Connection String:
In order to use “SqlClient” you have to use System.Data.SqlClient namespace following code will show you how to do it.
using System.Data.SqlClient;
Now you can use SqlClient for connection,dataset e.t.c what ever you like. Double click OK button and write following code:
SqlConnection sconn = new SqlConnection("User ID=Username;Password=Password;Initial Catalog=DB Name;Data Source=ServerName/IP");
Form1 formOne = new Form1();
Successful SuccessForm = new Successful();
sconn.Open();
DataSet ds = new DataSet();
SqlDataAdapter da = new SqlDataAdapter("select * from users where username ='" + TxtUsr.Text + "' and password='" + TxtPwd.Text + "'", sconn);
da.Fill(ds);
int count = ds.Tables[0].Rows.Count;
if(count==0)
{
MessageBox.Show("Invalid UserID/Password");
}
else
{
this.Visible = false;
SuccessForm.Visible = true;
}
sconn.Close();
The above code will first connect to the SQL Server 2000 database and then object of two forms “Form1″ and “Successful” as “formOne” and “SuccessForm” are initialized then all the operation with the database in order to validate the supplied “username” and “password” if the supplied username and password is correct then “SuccessForm” will be displayed otherwise following message box will be displayed:

Error Message
In order to close this form double cancel button and write following code:
Hope you have enjoyed this tutorial do not forget to give your feed back.