This article named Login Code In C# with SQL Server explains how to connect to SQL Server and create a login form in C# using Visual Studio and SQL Server Database as the project Back-End.
This simple tutorial you can learn on how to Create Login Window In C# Step by Step process with provided source code. In this tutorial also includes a downloadable source code for free.
Project Output
Here’s the Login Page in C# with SQL Server Database.
Login Page in C# : Project Details and Technology
Project Title: | Login Page Project In C# |
---|---|
Abstract : | Login Page in C# A login page is a web page or website entry page that requires user identification and authentication. |
Project Type: | Desktop Application |
Technology : | C# Visual Studio 2022 with C# Language |
Database : | SQL-Server 2021 |
To start creating this Login Page in C# make sure that you have a Microsoft Visual Studio and SQL Server installed in your computer.
Before we start if you want to learn login system in asp.net, just click the link given and you see the full tutorial on How To Create Login Page In ASP.NET MVC with Database.
Login Code in C# with SQL Server Free Source Code : Steps on how to create the project
Time needed: 5 minutes
These are the steps on How To Make Login Page in C#
- Step 1: Open SQL Server
Open SQL Server (enter the Server Name, Id and Password then click on Connect).
- Step 2: Create new database
Create a new database (right-click on Database then select New Database).
- Step 3: Name your database
Enter “Login” for the database name then click OK.
- Step 4: Create new table
Create a new table (explore the Login database then right-click on Tables then select New Table).
- Step 5: Design the table
Design the table (name the columns and set the data types as shown in the following figure).
- Step 6: Open Visual Studio
Create a New Web Application (open Visual Studio then select File -> New ->New Project).
- Step 7: Select Windows Form App
Next, select Windows Form App(.NET Framework).
- Step 8: Name your project
Next, name your project and then, click create button.
- Step 9: Copy the code given
Final, copy all code given below and paste to your file.
Complete Source Code
using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; using System.Data.Sql; using System.Data.SqlClient; namespace Login_System { public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void label2_Click(object sender, EventArgs e) { } private void button2_Click(object sender, EventArgs e) { Application.Exit(); } private void button1_Click(object sender, EventArgs e) { SqlConnection con = new SqlConnection(); con.ConnectionString = "Data Source=LAPTOP-AMM1MQ8C;Initial Catalog=Login;Integrated Security=True"; con.Open(); string userid = textBox1.Text; string password = textBox2.Text; SqlCommand cmd = new SqlCommand("select UserName,Password from LoginMst where UserName='" + textBox1.Text + "'and Password='" + textBox2.Text + "'", con); SqlDataAdapter da = new SqlDataAdapter(cmd); DataTable dt = new DataTable(); da.Fill(dt); if (dt.Rows.Count > 0) { MessageBox.Show("Login sucess Welcome to Homepage https://itsourcecode.com"); System.Diagnostics.Process.Start("https://itsourcecode.com"); } else { MessageBox.Show("Invalid Login please check username and password"); } con.Close(); } private void Form1_Load(object sender, EventArgs e) { SqlConnection con = new SqlConnection("Data Source=LAPTOP-AMM1MQ8C;Initial Catalog=Login;Integrated Security=True"); con.Open(); } private void textBox2_TextChanged(object sender, EventArgs e) { } } }
Summary
This article was developed using C# Programming and SQL Server as the system’s Back-End, This project also includes a downloadable source code for free.
Run Quick Virus Scan for secure Download
Run Quick Scan for secure DownloadDownload Source Code below
Related Articles
- Laravel Login Page With Source Code
- C++ Login System Source Code
- Login Page In CodeIgniter With Database
- Login Page In Javascript With Source Code
- Login and Registration DFD Levels 0 1 2 | Data Flow Diagrams
- Login Page Code In Java With Source Code
- Django Login And Registration With Source Code
- Login System in JavaScript with Source Code
- Login Page in Python with MySql Database
Inquiries
If you have any questions or suggestions about Login Page in C# MVC With Source Code, please feel free to leave a comment below.
Twas pretty good heyyy helped me alot thanks