Hey, Everyone, I hope you all of fine, in this tutorial, you will learn How to Create Login Form in C# with SQL Database. Login Form is used to sign user or administrator, then you will redirect another form as you like. Recently I have made the video tutorial on this topic, I want to share this knowledge for everyone. More than beginners or newbies users facing problems, this tutorial are helpful and beneficial for them.
First of All, you need to create a project and design Login Form as you like. Then you need to make a database with the help of SQL Server. After complete above process, you are able to connect Login form with SQL Server.
You May Also Like: School Management System in C#
I have made a project in Visual Studio Namely Login Form with Database. I have used two Labels, Two Text Boxes and One Button, Below I have shared a screenshot of this project.
C# Code for Login Form Using Database
Below I have shared Database Queries and Also Visual Studio C# Login Code. Below You can see them, then you will follow on my codes you will able to Create a Login Form in C# with SQL Database.
You May Also Like: Library Management System in C#
create table registration (Id int primary key identity (1,1), Name varchar(50), Pass varchar(50))
insert into registration values ('Administrator','admin'),('User','user')
login form in c# windows application with database
public partial class Form1 : Form
string conn = ("Data Source=DESKTOP-QG2VIHO\\SQLEXPRESS;Initial Catalog=tutorials;Integrated Security=true");
private void button1_Click(object sender, EventArgs e)
if (txtUName.Text == "" && txtPass.Text == "")
MessageBox.Show(" Please Enter The User Name & Password ");
SqlConnection con = new SqlConnection(conn);
SqlCommand cmd = new SqlCommand("select * from registration where [email protected] And [email protected]", con);
SqlDataAdapter adpt = new SqlDataAdapter(cmd);
DataSet ds = new DataSet();
int count = ds.Tables.Rows.Count;
if (count == 1)
catch (Exception ex)
private void Form1_Load(object sender, EventArgs e)
The Above all mentioned codes which are used to create a login form in C# with SQL Server Database. Furthermore, I have made a video tutorial on this topic, you can watch the video I hope this video tutorial is helpful and beneficial for you.
How to Create Login Form in C# with SQL Database
Thanks for Visit and Watch the Complete video, I hope have learned as well. Kindly, share on my content/course on social networks.
If you have any question/suggestion about this topic, kindly submit a single comment or email me. I will reply with your answer maximum 24 hours. Subscriber my Social Networks Pages and Email for getting updates. Thanks for the read and watch my video Tutorial.
You May Also Like: Java Database Connectivity with MySQL