C# SQL Database Tutorial 2: Add New ,Remove ,Save Data in Local Database using C#

preview_player
Показать описание
Saving Data to Database. How to insert data.

★★★Top Online Courses From ProgrammingKnowledge ★★★

★★★ Online Courses to learn ★★★

★★★ Follow ★★★

DISCLAIMER: This video and description contains affiliate links, which means that if you click on one of the product links, I’ll receive a small commission. This help support the channel and allows us to continue to make videos like this. Thank you for the support!

How to Add, save & retrieve data in SQL Server using C#
Help cant save data to sql database in c#
How to: Insert New Records into a Database
Database Access with Visual C#.NET
sql server - Insert Data into database in C#
How to insert Data to Ms SQL server 2008 using C#.net
.net - C# insert data into SQL table
Using Visual C# and SQL cannot insert data into table..‎
c# import data from text file into sql databse line by line‎
store xml in SQL Server 2008 from C#‎
Using SQL in C# - Cannot insert data into SQL table
visual C# - Could not Insert the data using VC# in MYSQl
Add, save & retrieve data in SQL
insert data into SQL table from pre filled boxes in C# 4.0‎
Insert DateTime into SQL Server using C#‎
Searches related to c# insert data into sql
c# insert data into sql table
c# insert data into sql server
inserting data into sql table
insert query
sql insert statement from another table
Рекомендации по теме
Комментарии
Автор

For those of you having issues with the updating of info from the datasource to the database and also for updated info showing on the windows form, try to follow these steps:

Step 1: 
Go to database explorer,  
right click database name (mdf file),  
select modify connections,  
select Browse,  
within your project folder, go into the bin folder, then go into the Debug folder,
select the mdf file in the debug folder,
select Test Connection to ensure connection succeeds, then click OK

Next, go to properties of the database (mdf file),
click the connection string box in the properties explorer menu,
copy the data source file path in the connection string box

Step 2:
In the Solutions Explorer box, double click 'Properties',
go to Settings option,
Insert Name - (can be anything you want, I named mine EmployeeConnString)
Insert Type - In the dropdown box, select connection string
Insert Scope - in the dropdown box, select application
Insert Value - right-click paste (previously copied file path), press enter
You can exit this tab

Step 3:
Go back to the solutions explorer box and select the database file in your vs project(mdf file),
Go to the properties explorer window to the copy to output directory option,
change "Copy Always" to "Copy Never" or "Do Not Copy",

These steps worked for me and now everything I enter updates correctly, as well as when i re-run the application, the updated data shows in the new form box.

lprince
Автор

The save button does nothing for me when i restart the program the records i saved are no longer there

nathanm
Автор

Hi again, i just wanna say.. it works now... i can edit the items.. i follow manually create "add new - save and remove" i create new one existing .sdf file then new data source.. and for binding navigator i insert manually from toolbox menu. i link it the BindingSource to my tblBindingSource and replace with yours add, remove, save and the status code too ... thanks again ... i loVe C# :-D

simsee
Автор

hello there, when i click save and then close the program and re-run the data which i entered before is no longer there.
how can i update the database with the data entered when i run the application ?

amrmohamed
Автор

Hi, I did this but when i remove or edit rows in the gridview i can't save my changes and the rows comeback after opening the program again.
How can i save my changes???

mohammadaminsarbazi
Автор

Thank you very much. Very clear and helpful (as all your videos)

shivayogaji
Автор

Hello, sorry for my bad english..., however...I want to aks you something. I did everything from the first and second videos, but I have a problem. When I start the program and delete a row and click the, ,save,, button, the program stops running and  shows me that the deleting command is unvalid. How can I fix this problem?

dragonfly
Автор

Question here, what makes these 3 new buttons diffrent from the plus, cross and save icons in the top of the form?

andriesbakker
Автор

Hi there, I cannot find the employeeInfoBindingSource function. Could you please tell me which libraries are you using? Thanks

peetman
Автор

Thank you very much for this, I have been following your tutorials. Now from this project please please teach us how to print or reporting in visual studio. Thanks once again.

gxlaire
Автор

Hai, I am developing a game using WPF. In wpf 1 the user enters his details once his click on submit button his details stores in database and automatically enters into wpf2 to play game. after finishing the game the score should automatically store in database(important). i struck up here. Which method i need to implement inorder to store score in database. and should display wpf3. In wpf3 the user should be accessed top 5 highscores that played last time.

shrav
Автор

Hello :)

I probably had concerns with the invalid InvalidOperationException.. It exist after I change the saved data information in my database with subconciously non update operation yet. What should I do? It also results to malfunction of save button

marijoycasanas
Автор

How you fixed "NoNullAllowedException was unhandled" error? 5:30

gunterertan
Автор

Sir. i have created my database application in c#, but i want to create a setup of it to deliver it to the client but there is no correct lecture on it. the other lecture i have searched didn't work. Please create a video on it. i will be very thankful to you.

engrnasirshah
Автор

Hi there, thanks for your great share video tutorial... but i have some error. i think i got mistaken how to configure VS 2012 or something. i get this error message when i try to save/update my saved item.. it say "Update requires a valid UpdateCommand when passed DataRow collection with modified rows." any suggestion ? please help. my OS win8 VS 2012

simsee
Автор

This solution is not efficent in large data tables. In form load You do fill table adapter with all the data. If You have ex. 100k records You fill all in. The best approach is to make datagridview and table add or remove on separate forms with separate bindingsources with where conditions

xcysio
Автор

يمكنك ايضا وضع هذا الكود فى زر الاضافة لجعل قلم الكتابة عند حقل ID
 iDTextBox.Focus();

bastawymona
Автор

This works, thanks!
However, this doesn't work when i have two local databases. I do the exact same thing second time, but i get:
"throw new error, or something similar.
And it's because of this line of code (i think):



I have Books database and Members database,

Please help!

saywhat
Автор

is there anyway i can insert my data using listbox instead of textbox. E.g, scanning for bluetooth devices thn the results will populate into the listbox, so from there, I insert the data into my database. Is it possible? 
Thanks for the vid ^^

gracekuangyl
Автор

What to do?

"Update requires a valid UpdateCommand when passed DataRow collection with modified rows." keeps on showing every time I click the save button (button2)
private void button2_Click(object sender, EventArgs e)
        {
            this.Validate();
           
             <---- in this line InvalidOperationException was unhandled

justinetragico
visit shbcf.ru