Visual Studio 2015 with My SQL connection PDF

Title Visual Studio 2015 with My SQL connection
Author FIKADU WAYESA
Course Event Driven Programming
Institution Wachemo University
Pages 15
File Size 1.2 MB
File Type PDF
Total Downloads 70
Total Views 191

Summary

This manual enables you how to integrate C# with MySQL database....


Description

Visual Studio 2015 with MySQL connection (Database Connection Manual) Steps 1. You need to download MySQL Connector/NET from

https://downloads.mysql.com/archives/c-net/ that is compatible with the .Net framework of your C# (For Microsoft Windows). 2. After you download the connector, Install it (In my case I have downloaded MySql Connector 6.9.8.0 that is compatible with my .NET

Click Next

Click Typical, then click Next Click Install and then Wait Now when the installation successful, go to your Visual Studio and follow the following Go to solution Explorer, (If you can’t find it, Click view Solution Explorer) 1|Page

Right click on References and Select Add Reference

Click Browser and select C:\Program Files (x86)\MySQL\MySQL Connector Net6.9.8\Assemblies\v4.5\MySql.Data.dll Now you have successfully imported the connector to your program and you can establish connection. To establish a connection Follow the following steps 1.

Start Visual Studio.

2|Page

2.

On the View menu, click Server Explorer.

3.

Click the Connect to Database icon. The Choose Data Source dialog box appears.

4.

In the Data source list box, select MySQL Database, and then click Continue.

You can download from this Site https://downloads.mysql.com/archives/visualstudio/ MySQL for Visual Studio is an add-on for Microsoft Visual Studio that simplifies the development of applications using data stored by the MySQL RDBMS. Many MySQL for Visual Studio features also require that MySQL Connector/NET be installed on the same host where you perform Visual Studio development.

Right Click on Data Connections

Click Add new Connection

3|Page

Click Change, Then Select MySQL Database

4|Page

Click Ok and you get the following form,

To fill the above form, you have to do the following tasks first. Start the XAMPP and start both Apache and MySQL

5|Page

Click Admin

Click phpMyAdmin and create a database called ‘SRS’

Select the database you created “SRS” Create table(s) you want in that database Now to know where this database is existed Click on “Privileges”

Hostname is: Localhost, username is: root and password is empty.

6|Page

Then click “Test Connection”. If the connection is successful, you will get the following.

After the successful connection, click Ok. Now you have successfully established the connection and find the path in the Server Explorer. 7|Page

Now let we make a login Form in the Visual Studio Step 1 Open Visual Studio you have installed in your machine; I have Visual Studio 2015. When open it will look like this:

Step 2 Click on the middle tab of new project. When you click it will look like this:

8|Page

Step 3 In Installed Templates the first option is Visual C# language and then select Windows Forms application. In the following see the Name label and already show the default name WindowFormsApplication7. You can change the name as you wish or as per program creation you can mention and click and OK. Step 4 After clicking OK a simple Windows Forms form will look like:

9|Page

Step 5 In your Windows Forms form set the size as needed. You can set the size and if you want to set the size by properties then right-click on the Windows Forms form and in the last option of show properties click to see the Windows Forms form properties.

10 | P a g e

Set the Windows Forms form name and show text in the specified properties. If you wish you can set the form1 name; my form1 name is “Log in Form”. Click the Toolbox and drag and drop two buttons and two labels and two TextBoxes as in the following:

Step 6 Then you need to change the lable1 name to User Name and label2 to Password then for the Buttons change the button1 right-click property to show text select button1 and type &Log In and button2 &Cancel. where & is used for a small Underline only one first text look up. See the image button1 to show the Log In and button2 show Cancel for style . Step 7 Now drag all text boxes and labels and buttons and arrange all the tools. Then right-click each tool one by one and set the properties for font and color. Look at the following:

11 | P a g e

All sets of fonts and font size and if you want to set the image background set and form icon also you can set and more things and tab index set serially for all tool of labels, TextBox and buttons.

Now the final design looks like this type. Step 8

12 | P a g e

To connect with a SQL Server database right-click on the form and click on properties then go to the upper second option (Data Binding). In Data Binding click the text area and it will look like:

Let we check if the User Name and Password value we entered is existed in the Database “SRS” of table called “Login”, the system will return “Correct” otherwise “Incorrect” when the Login button is clicked.

13 | P a g e

For Example Username=Fikadu and Password=Fikadu123 This should return success because the user name and password is existed in the database.

Click Login button

If one of the above is incorrect, the system will display

14 | P a g e

15 | P a g e...


Similar Free PDFs