C# Windows Form Application And Microsoft SQL Database Insert Update Delete Retrieve/Select/Display (CRUD)

Windows Form Application C# And Microsoft SQL Database Insert Update Delete Retrieve/Select/Display (CRUD)

This a complete (crud) Create, read, update and delete, C# Windows Form Application And Microsoft SQL Database Application/program. This desktop app demonstrates how to insert, update/edit, delete and select/retrieve data from Microsoft SQL server database and display retrieved data on c# treeview.

How To Connect To Microsoft SQL Server Database Using Microsoft SQL Server Management Studio

To access Microsoft SQL Server database you need to pass some database properties like database name and server name in sql connection string.

Below is an example of a connection String

string connectionString = "Data Source=DESKTOP-C7B0LHA\\SQLEXPRESS;Initial Catalog=Staff;Integrated Security=True";

You can get the server name when Microsoft SQL Server Management Studio is starting. As shown below.

Database.

TABLE CREATION QUERY

SID Column Auto Increments Whenever a new record is added to the database. It’s also the table primary key, that means only unique data is accepted/allowed.


USE [Staff]
GO

/****** Object:  Table [dbo].[Newstaff]    Script Date: 6/3/2021 3:50:18 AM ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

CREATE TABLE [dbo].[Newstaff](
	[SID] [int] IDENTITY(1,1) NOT NULL,
	[Fname] [varchar](150) NOT NULL,
	[lname] [varchar](150) NOT NULL,
	[gender] [varchar](20) NOT NULL,
	[dob] [varchar](100) NOT NULL,
	[mobile] [bigint] NOT NULL,
	[email] [varchar](150) NULL,
	[joindate] [varchar](100) NOT NULL,
	[city] [varchar](100) NOT NULL,
	[basicSalary] [decimal](8, 2) NULL,
	[post] [varchar](max) NULL,
 CONSTRAINT [PK_Newstaff] PRIMARY KEY CLUSTERED 
(
	[SID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
GO


SOURCE CODE

SCREENSHOTS

SOFTWARES

  1. Microsoft Visual Studio 2015
  2. Microsoft SQL Server Management Studio

DEMO VIDEO

Leave a Reply

Your email address will not be published. Required fields are marked *