Welcome to the FoxLearn Today we will learn how to insert, update, delete and view data from database First, You need to install metro framework from nuget Metro Modern UI or MetroFramework brings Windows 8 UI to .NET Windows Forms applications. We will design a simple UI allows you to insert, update, delete and view data from sql server You should create a new database, then add a student table to your database You need to set identity is true Auto-increment allows a unique number to be generated when a new record is inserted into a table We will create stored procedure to insert, update data A stored procedure is nothing more than prepared SQL code that you save so you can reuse the code over and over again So if you think about a query that you write over and over again instead of having to write that query each time you would save it as a stored procedure and then just call the stored procedure to execute the SQL code that you saved as part of the stored procedure In addition to running the same SQL code over and over again you also have the ability to pass parameters to the stored procedure so depending on what the need is the stored procedure can act accordingly based on the parameter values that were passed You need to create a student class to mapping data return from sql server You can add an EntityState to manage your object state You should add a connection string to the app.config file We always use Connection String in forms that we design, but when you design a big software you should set the connection string for once and use it in many forms In this method you use the name of the Connection String instead of the connection string text Every time you want to change the connection string just change the main connection string in the App.Config file By this method you don’t need to change all of the forms in your project, just change the Connection String in the app.Config You need to add a binding source to metrogrid The BindingSource component serves two purposes First, it provides a layer of indirection when binding the controls on a form to data This is accomplished by binding the BindingSource component to your data source, and then binding the controls on your form to the BindingSource component Second, the BindingSource component can act as a strongly typed data source You need to install ado.net from nuget This package delivers an ADO.Net library Provides a fluent interface to throw some SQL or DDL at your database Compatible with all ADO.Net providers, in as far as they implement the ADO.Net interfaces correctly You can add query to retrieve data from student table You can call stored procedure from stored procedure method Thank you for watching this video

C# Tutorial – Insert Update Delete View data from database using ADO.Net | FoxLearn

Leave a Reply

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