Appendix A

Visual Studio Community 2015

Visual Studio 2015 is the latest Integrated Development Environment (IDE) from Microsoft for building web, mobile and desktop applications. One of the versions of this software is Visual Studio Community 2015. The community edition is free forever as long as you register.

This appendix provides a quick tutorial to using Visual Studio Community 2015.

Hardware and Software Requirements

To run Visual Studio Community 2015, you need a computer with the following specification.

  • ? 1.6 GHz or faster processor
  • ? 1 GB of RAM
  • ? 4 GB of available hard disk space

Visual Studio Community 2015 runs on these operating systems.

  • ? Windows 10
  • ? Windows 8.1
  • ? Windows 7

Download and Installation

You can download the installer for Visual Studio Community 2015 free from this Microsoft website:

https://www.visualstudio.com

To install the software, follow these steps.

1. Double click the installer you just downloaded. Make sure you are connected to the Internet because there are other files that need to be downloaded. You’ll see the dialog like the one in Figure A.1. This dialog is the first of a series of windows in the Setup wizard.

2. Agree to the license terms and conditions by clicking the “I agree ...” checkbox and you’ll see an Install button at the bottom.

3. Click the Install button.

4. Windows will ask if you want to let the Setup program run. Click OK.

5. Now, sit tight and wait as the wizard downloads the necessary programs and preparing your system. It will take a while but don’t go away. At one stage, the wizard will ask you to restart your computer. When that happens, restart it.

6. When your computer is back up, the same wizard will resume its work. Keep waiting.

7. Finally,when it’s really done, you’ll see the dialog like the one in Figure A.2.

8. Click LAUNCH.

Figure A.1: The first installation dialog for Visual Studio Community 2015

Figure A.2: The last installation dialog for Visual Studio Community 2015

You’ll be able to use this product for 30 days, after which you’ll need to register to continue using it. Don’t worry, registration is free.

Figure A.3: Starting Visual Studio Community 2015

Congratulations. You’re now ready to program.

The Visual Studio 2015 application icon has been moved outside of the Visual Studio 2015 folder. If you're running Windows 7, you can find the application right under the "All Programs" list. If you are running Windows 8, 8.1 or 10, you can find it under the ‘Visual Studio’ grouping. If you are still unable to find it, use Windows search (press the Windows key, then type “Visual Studio 2015”).

In Windows 7 the application icon is no longer located in the Visual Studio 2015 folder.

Figure A.4: Where to find the application icon in Windows 7

Registering Visual Studio Community 2015

Visual Studio Community 2015 is free. However, Microsoft wants you to register your copy with them if you are planning to use it for more than thirty days. Don’t worry, registration is free.

You know it is time to register when you get a warning dialog when you open Visual Studio Community 2015. You will be asked to sign in with a Microsoft account. If you don’t have one, you will need to create one.

Creating a Project

Visual Studio Community 2015 organizes resources in projects. Therefore, before you can create a C# class, you must first create a project. To do so, follow these steps.

1. Click File > New > Project. The New Project dialog will be displayed (See Figure A.5).

Figure A.5: The New Project dialog

2. Select Visual C# from under Installed > Templates, and then click on Windows.

3. Select an application type from the center pane. For this book, you will create either a Console application or a WPF application.

4. Enter a project name in the Name box and browse to the directory where you want to save the project’s resources. Afterward, click OK.

  • Visual Studio Community 2015 will create a new project plus the first class in the project. This is depicted in Figure A.6.

Figure A.6: A C# project

Creating a Class

To create a class other than that created by default by Visual Studio, right-click on the project name in the Solution Explorer widget and click Add > Class. In Figure A.6 the widget is located on the left. If you do not see the Solution Explorer widget, click View > Solution Explorer.

In the “Add New Item” dialog like the one in Figure A.7, enter a class name in the Name box and click Add. Alternatively, you can open the Add New Item dialog by pressing the shortcut Shift+Alt+C.

Figure A.7: The “Add New Item” Dialog

Running a Project

To run a project, press F5. Visual Studio will compile the project and run the class with a Main method. You can only have one Main method in a project.

Visual Studio will catch any compile or build errors before it runs a project.

Working with Databases

Visual Studio is not just a compiler, it ships with a lot of useful tools for developers. One of the tools allows you to connect to a relational database or create a new one and manipulate its data. You can create tables, update the data in the tables, run SQL queries and so on.

Visual Studio also comes with LocalDB, a minified version of SQL Server Express built for developers. LocalDB requires no maintenance and can be started by another program. LocalDB is suitable for development.

Creating A Database

You can easily connect to an existing database or create a new one. The supported data sources are:

  • Microsoft Access Database File
  • Microsoft ODBC Data Source
  • Microsoft SQL Server
  • Microsoft SQL Server Database File
  • Oracle Database

To create a database, follow these steps:

1. Click Tools > Connect to Database. You will see the dialog in Figure A.8.

Figure A.8: Adding a data connection

2. Select the database type. For this example, select Microsoft SQL Server Database File.

3. Click the Browser button and navigate to a folder that will be the location of your database file.

4. Type MyDB.mdf as a file name and click Open. When you are back to the Add Connection dialog, keep the authentication method (Windows authentication) and click the OK button.

5. Visual Studio will ask if you would like it to create a new database file. Click Yes.

6. The Add Connection dialog will close. Now click SQL Server Object Explorer from the View menu or click the tab on the left edge of Visual Studio. Figure A.9 shows the SQL Server Object Explorer window. You should see a (localdb) entry under SQL Server.

7. Expand the (localdb) node and you should see MyDB (your newly created SQL Server database file) under the Databases node.

Figure A.9: SQL Server Object Explorer

Creating A Table

To create a table in a database, follow these steps.

1. If not already open, open SQL Server Object Explorer and expand the SQL Server node until you see your database in which you want to create a table (See Figure A.9).

2. Right click on the Tables node under the database node (e.g. MyDB), and select Add New Table from the popup menu. The table designer like that in Figure A.10 will open.

Figure A.10: The table designer

3. Add fields with the correct data types. As you add more fields, the T-SQL window at the bottom will update the script to include the fields. When you are finished adding fields, change the table name from CREATE TABLE [dbo].[Table] to CREATE TABLE [dbo].tableName, replacing tableName with the actual name of your table.

4. Click the Update button. In the dialog that appears, click Update Database. The table should be added to the Tables node under your database, as shown in Figure A.11.

Figure A.11: A new table (Employee)

Editing Data in A Table

To add, delete or update data in a table, right-click on the table name in the SQL Server Object Explorer window and select View Data.

Figure A.12 shows the data view of the table. Feel free to add, delete and edit the records.

Figure A.12: The data view

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.17.154.171