Database connection

Fundamentals of info property
C# and .Net will work with a majority of databases, the foremost common being Oracle and Microsoft SQL Server. however with each info, the logic behind operating with all of them is usually a similar.

In our examples, we are going to check up on operating the Microsoft SQL Server as our info. For learning functions, one will transfer and use the Microsoft SQL Server categorical Edition, that may be a free info computer code provided by Microsoft.

In operating with databases, the subsequent ar the ideas that ar common to all or any databases.

Connection – to figure with the info in an exceedingly info, the primary obvious step is that the association. The association to a info ordinarily consists of the below-mentioned parameters.
Database name or knowledge supply – the primary necessary parameter is that the info name to that the association must be established. every association will solely work with one info at a time.
Credentials – ensuing necessary side is that the username and arcanum that must be wont to establish a association to the info. It ensures that the username and arcanum have the required privileges to attach to the info.
Optional parameters - for every info kind, you'll specify optional parameters to produce a lot of data on however .net ought to handle the association to the info. for instance, one will specify a parameter for the way long the association ought to keep active. If no operation is performed for a selected amount of your time, then the parameter would confirm if the association has got to be closed.
Selecting knowledge from the info – Once the association has been established, ensuing necessary side is to fetch the info from the info. C# will execute 'SQL' choose command against the info. The 'SQL' statement may be wont to fetch knowledge from a selected table within the info.
Inserting knowledge into the info – C# may be wont to insert records into the info. Values may be laid out in C# for every row that must be inserted into the info.
Updating knowledge into the info – C# may be wont to update existing records into the info. New values may be laid out in C# for every row that must be updated into the info.
Deleting knowledge from a info – C# may be wont to delete records into the info. choose commands to specify that rows got to be deleted may be laid out in C#.
Ok, currently that we've seen the idea of every operation, let's jump into the additional sections to appear at however we are able to perform info operations in C#.

How to connect C# to info
Let's currently check up on the code, that must be unbroken in situ to make a association to a info. In our example, we are going to connect with a info that has the name of Demodb. The credentials wont to connect with the info ar given below

Username – admin
Password – demo
We will see a straightforward Windows forms application to figure with databases. we are going to have a straightforward button known as "Connect" which can be wont to connect with the info.continue Reading

Leave a Reply

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