Database Operations in C#


The most common databases used in C# are Microsoft SQL Server and Oracle. The following is done to work with databases.

Connect

Set the Database Name, Optional Parameters and Credentials. The username and password is needed to set a connection to the database.

The connection string would look somewhat like this.

private static string _connectionString = "Data Source=.;Integrated Security=SSPI;Initial Catalog=test;Application Name=Demo;Connection Timeout2w00";  

Above, the Application Name is Demo.

Select Statement

To fetch data from the database, the SELECT statement is used

Insert

The INSERT command is used to insert data in the database.

Update

The database needs to be updated for new records. In that case, use the Update command.

Delete

Delete records from the database by selecting the rows you need to delete.

Samual Sam
Samual Sam

Learning faster. Every day.

Updated on: 30-Jul-2019

1K+ Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements