Easiest Way To Connect Application With database [MySQL] Using C# !!

Easiest Way To Connect Application With database [MySQL] Using C#




Added On : 04 - Feb -2018

First Step :

To connect your VISUAL STUDIO's C# program with Database , first you have to download SQL Server Management Studio ..

Download SQL Server 2012 Express from the link below:

If you find  any difficulties in downloading SQL Server then this video given will surely help you !!

INDRA SUBEDI TUTORIAL

This tutorial is not our all credit goes to respective owner .
   OWNER : INDRA SUBEDI
   HIS CHANNEL LINK : OPEN CHANNEL !
   HIS DESCRIPTION ON VIDEO :
   How to download and install SQL Server 2012 - Installation step by step | How to install sql server 2012
Channel Subscription : https://goo.gl/FZrbXg Affilate: http://amzn.to/2DPwG8d Link to download sql server 2012: https://www.microsoft.com/en-us/downl...

ALL RIGHT GOES TO INDRA SUBEDI

Second Step :

After downloading SQL Server , You have to make a DATABASE ...

How to make a DATABASE?

You can create a DATABASE by clicking New DataBase.. on Databases folder found in Object Explorer..  (SQL Server)

Third Step:
After creating a DATABASE , connect it with C#..

How to connect SQL?

In Microsoft Visual Studio's ToolBar , choose TOOLS and go to CONNECT TO DATABASE..

An Add Connection Box will display as shown above , Enter your Server Name (My server name is DOT (.) ) .. Then Select your Database name which you had created in Step 2 (My DataBase name was WORLDTRUESIGHT)...
Then Click on Test Connection .. If your Test Connection succeed , it's mean your Data Base connected successfully..

Fourth Step:

After connecting DataBase successfully, Open  Server Explorer ( present on the Left Side in Visual Studio) .. It shows your connection ..


Right click on this DATABASE will open a window .. Go to properties.. This properties window contains a CONNECTION STRING..
Copy this ConnectionString (Data Source=.;Initial Catalog="WORLDTRUE SIGHT";Integrated Security=True) , With the help of this ConnectionString you can make a Connection class ..

Fifth Step :

How to create a Connection Class ?

Make a connection class like this :
Add Libraries in order to access database commands ,

using System.Data;
using System.Data.SqlClient;

  • Paste the ConnectionString you saved from Properties (In Fourth Step)
  • Create constructor with connection class to open a new connection and it will be saved automatically in "HEAP" memory.
  • Create method with SqlConnection namely Connect and open the connection in it !
  • Similarly, create another method to close the connection in it !
CODE SIMPLIFY THINGS



Hope you learn from it -----------------------------------
Comment below for any query !



Post a Comment

2 Comments

  1. Fascinating. Definitely bookmarking this page. Really valuable info, thanks for posting.
    Search Engine Optimization

    ReplyDelete
  2. I read your blogs regularly. Your humoristic way is amusing, continue the good work!
    Male Sex Toys

    ReplyDelete