0% found this document useful (0 votes)
52 views6 pages

Technologies

Uploaded by

aksumgere
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
52 views6 pages

Technologies

Uploaded by

aksumgere
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 6

Insert Data Into The Database In Windows Form Using C#

Nilesh Jadav Nilesh Jadav Oct 10, 2015

580.2k 32 7

[Link]

Initial chamber

Step 1: Open Visual Studio 2010. Go to File, New, Projects and under Visual C# select Windows.

window form

You can change the name of the project and browse your project to different location too. And then
press OK

Step 2: In Solution Explorer you will get your Project Add Service Based Database by going to your
Project. Right click and Add New Item, then select Service-based Database.

Service Based Database

Database chamber

Step 3: Go to your Database [Link] and we will create a table tbl_save. Go to the [Link],
then Table and Add New table. Design your table like the following screenshot:

Tbl_save:

Table
Design chamber

Step 4: Now open your [Link] file, where we create our design for inserting data into the database.
We will drag three labels, three textbox and one button from the tool box to [Link]. You will see your
Form look like the following screenshot:

[Link] [design]:

form

Code chamber

Right click on the blank part of [Link], then click View Code. You can see you are entered in the code
part of the form. Write the following code and then Press F5 to run the project.

[Link]:

using System;

using [Link];

using [Link];

using [Link];

using [Link];

using [Link];

using [Link];

using [Link];

using [Link];
namespace Insert_data_into_table

public partial class Form1 : Form

public Form1()

InitializeComponent();

private void button1_Click(object sender, EventArgs e)

//SqlConnection con = new SqlConnection("Data Source=NiluNilesh;Integrated Security=True");

SqlConnection con = new SqlConnection(@"Data Source=.\SQLEXPRESS;AttachDbFilename=|


DataDirectory|\[Link];Integrated Security=True;User Instance=True");

SqlCommand cmd = new SqlCommand("sp_insert", con);

[Link] = [Link];

[Link]("@name", [Link]);

[Link]("@email", [Link]);

[Link]("@phone", [Link]);

[Link]("@address", [Link]);

[Link]();

int i = [Link]();

[Link]();

if (i!=0)
{

[Link](i + "Data Saved");

public static void main(string[] args)

[Link](new Form1());

Output chamber

Output

Data in the Database:

Data in the Database


[Link]#Insert Data into DatabaseWindow form

RECOMMENDED FREE EBOOK

C# Corner Ebook

[Link] GridView Control Pocket Guide

Download Now!

SIMILAR ARTICLES

Insert Data Into Excel Using [Link]

Inserting Images in a Window

Inserting Form Data Into DataBase Using Stored Procedure In [Link] C#

Insert Data Into Database in Windows Forms

Insert Data Into Database by Stored Procedure in [Link] C#

Nilesh Jadav Nilesh Jadav Top 100

Subscribe my Channel : [Link] Nilesh is professionally an


[Link] developer, SEO and Blog writer at Citadel Infotech. He is having competent knowledge of
[Link], C#, HTML, AJAX, AD... Read more

[Link]

8115.2m2

View All Comments

32

Type your comment here and press Enter Key (Minimum 10 characters)
About Us Contact Us Privacy Policy Terms Media Kit Sitemap Report a Bug FAQ Partners

C# Tutorials Common Interview Questions Stories Consultants Ideas Certifications CSharp TV

Web3 Universe Build with JavaScript Let's React DB Talks Jumpstart Blockchain [Link]

©2024 C# Corner. All contents are copyright of their authors.

የመጀመሪያው ጽሁፍ

ለዚህ ትርጉም ደረጃ ይስጡ

ግብረመልስዎ Google ትርጉምን ለማሻሻል እንዲያግዝ ሥራ ላይ ይውላል

You might also like