Hello, Everybody, I hope you all of fine, today we will learn How to Save Data in Database Using C#. Basically, there are different ways to Save Data in Database using C#, but I will tell very simple and useful method. More than beginners they are learning C#, they are facing many problems which methods used to develop the application.
I already told you, there different ways to Save Data in Database using C#. I don’t confirm, C# developers which methods used to develop the application. I have been working in C# to develop applications. I have used two popular methods such as String and LINQ to Save, Update, Delete, View and Also Search Record using C# and SQL Server Database.
If you want to develop an application with the help of C# and SQL Server. You must include Insert, Update, Delete, View and Search Futures. Without use, these futures your application doesn’t an application.
You May Also Like: Fill Combobox From Database in C#
So, I want you will learn how to save data in a database using C# with String Method. Basically, String means you will use strength SQL Queries in the Windows Form Application. I am using String mode to develop the application in C# and SQL Server.
How to Insert Data in Database in C# Windows Application
First of All, you need to create a project in Windows Form Application. Then you need to design a simple Form, I have designed form and I have used Four Text Boxes, One Button, and One Grid View. You can design a form on depending your work.
You May Also Like: How to Generate QR Code in C#
After the creating a project in Windows Form Application, then you need to create a Database in SQL Server. Then you will be able to make a connection between C# Windows Form Application and SQL Server.
You May Also Like: Crystal Reports Tutorial For Beginners
After the database, then you need to generate an event on the button. Then you need to follow on my C# codes, then you used below codes to Save Data in Database Using C#.
public partial class Form1 : Form
SqlConnection con = new SqlConnection("Data Source=DESKTOP-QG2VIHO\\SQLEXPRESS;Initial Catalog=tutorials; Integrated Security=True;");
private void btn_Insert_Click(object sender, EventArgs e)
if (txt_Name.Text != "" && txt_Email.Text != "" && txt_Contact.Text != "" && txt_Country.Text != "")
cmd = new SqlCommand("insert into employees values('" + txt_Name.Text + "','" + txt_Email.Text + "','" + txt_Contact.Text + "','" + txt_Country.Text + "')", con);
MessageBox.Show(" The Data Has Been Saved in the Database");
MessageBox.Show(" Please Fill in the Blanks");
catch (Exception ex)
Above mentioned C# codes, which is used to Save record in the database and also connection codes available. Now, I have shared the video tutorial on below, you can watch it for getting more ideas.
How to Save Data in Database Using C#
Thanks for Visit and Watch the Complete video. I hope you 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.