Web design and hosting, database, cloud and social media solutions that deliver business results
  • Business Solutions
    • Robotic Process Automation
    • Software
    • Database Consultancy Services
      • Data Integration
      • Datawarehouse Services
      • Power BI
      • Server Upgrade and DBA Services
    • Web Site Design Services
      • Logo Design
      • Payment Gateways
      • Web Localisation and Translation
      • Web Site Optimisation
      • Web Site Security
      • Technical Tools
    • Cloud Services
      • Amazon Web Services
      • Google Cloud Services
      • Microsoft Azure
    • Microsoft Office
    • Social Media Management and Advice Services
  • Academy
    • Our Test Environment
    • Learning Databases
      • The Basics
      • Get Open Query
      • SQL Server Data
      • SQL Server Maintenance
      • Using SQL Server Dates
      • Using SQL Server Functions
      • Using SQL Server Pivot-Unpivot
      • Technical Tools
    • Learning Web Design
      • Building Ousia Content Management System
      • Using ASP-NET
      • Using CSS
      • Using JavaScript
    • Learning Cloud and IT Services
      • Task Scheduler Error 2147943645
      • Requesting SSL and Generation of PFX file in OpenSSL Simple Steps
    • Using Social Media
      • Asking for a Google Review
      • Changing a Facebook account from personal to business
      • Choosing where to focus Social Media effort
      • Social Media Image Sizes
      • Using Meta Data to set Social Media Images
  • About Us
    • Blog
      • Building an entry level gaming machine
      • Google Core Update Jan 2020
      • Hot Chilli Internet Closure
      • How To Choose Content For Your Website Adverts Leaflets
      • Preventing Online Scam
      • Skimmers of the gig economy
      • The most annoying things about websites on the Internet
      • Top 5 websites for free Vector Graphics
    • Careers
      • Translator English-Portuguese
      • Translator English-Spanish
    • Portfolio
    • Team
      • Adrian Anandan
      • Ali Al Amine
      • Ayse Hur
      • Chester Copperpot
      • Deepika Bandaru
      • Gavin Clayton
      • Sai Gangu
      • Suneel Kumar
      • Surya Mukkamala
Deutsch (DE)English (EN-GB)English (EN-US)Español (ES)हिंदी (HI)italiano (IT)日本語 (JA)polski (PL)Português (PT)Türk (TR)

Academy Test Environment

A lot of our articles depend very heavily on having a coding environment already, so we will walk through the setup here

Adding Context

To run through a lot of our tutorials you would need an active project of some sort, to add context to all of our articles, we are going to create a Visual Studio 2019 Solution, and also an SQL Express 2019 database.

Install Visual Studio

We build all of our applications within Visual Studio, so if you haven't got that, then download it from https://visualstudio.microsoft.com/downloads/

We wrote this in Visual Studio 2019, using the language Visual Basic, and times move so quickly that there may be parts of the articles that don't apply, or aren't in the same format as you see if using a different version.

Minimum items to install;

  • ASP.NET and web development
  • .NET cross-platform development

When using newer versions of Visual Studio then make sure you install the .NET Framework 4.7.2 targeting pack and the highest number SDK and Targeting Pack from the individual components tab to ensure that the templates required are installed.

Once you have downloaded and installed, then you should be able to follow the rest of the articles.

Create New Project

VS_0_CreateEmpty.PNG
First step is to create a new project, there are hundreds of templates available, the one we are looking for is ASP.NET Web Application.

Name your project

Name your project ClaytabaseAcademy, unless you are limited on space you can leave all of the other items as they are.

Items to Add

VS_2_References.PNG
During the lifetime of this project we will add certain references, but as a business our aim has always been to keep code bloat down, so don't add any references, they will only slow down your application.

Install SQL Server Express

SQL_0_Connection.PNG
You will also need a copy of SQL Server installed, you can get a version free at https://www.microsoft.com/en-gb/sql-server/sql-server-downloads.

The install can be done using all of the standard settings.

Keep a copy of your connection string as highlighted in the screenshot to the right, you will need it later.

You can also get a copy of SQL Server Management Studio by clicking on the "Install SSMS" button from here.

Install SQL Server Management Studio

CD_0_CreateDatabase.PNG

SQL Server Management Studio can be found at https://docs.microsoft.com/en-us/sql/ssms/download-sql-server-management-studio-ssms?view=sql-server-ver15, you will be looking for the section "Free Download for SQL Server Management Studio (SSMS)" in the main body of the page.

This program can be installed with all of the default settings.

Once installed, you can then open it up, it can be found under Microsoft SQL Server Tools, and then SQL Management Studio

The database connection on the first popup should be available under "localhost\SQLEXPRESS".

Once connected, select "New Query", and use the following command to create a database "CREATE DATABASE ClaytabaseAcademy"

You can use any other databases or servers in your IT estate, you will just need to adapt code as necessary to fit any articles.

Edit the web.config file in Visual Studio

Add Connection String

In Visual Studio, find your Web.config file and modify the contents of the to the snippet below.

We are also adding references for MVC and a couple of other modules at this stage and setting the .NET version.

                                                                                                                   

Add an ASP.NET folder

Right mouse button on Claytabase Academy and select Add > Add ASP.NET Folder > App_Code

Create a Public Class to share the connection string easily 

CS_2_Add_GlobalVariables.png

For ease of use, we can now create a Public Class to easily reference the SQL Connection in code elsewhere.

To do this, right click on the newly created App_Code folder and select Add > Class, we will call this GlobalVariables. The content of this file will be updated with the ConStr element below that we will use in other articles.

Public Class GlobalVariables    Public Shared ConStr As String = ConfigurationManager.ConnectionStrings("SqlConnection").ConnectionStringEnd Class

This is also a useful place for any other shared information you may want to share.

A Gotcha: Once added, right mouse button on this item and select properties, change the Build Action to Compile

Create a Global.asax file

We will go through more detail in a separate article, but add a Global class to control your application.

To do this right click on Claytabase Academy and select Add > New Item and look for Global Application Class within the Web folder, leave the name name as Global.asax.

This file will need to be modified with the following;

  • Import System.Web.Routing so that we can access the routing features
  • Add a new sub, RegisterRoutes, in which we can add all of our dynamic routes further down the line
  • Reference this new RegisterRoutes sub in the Application start, so that it gets loaded straight away.

Full code is set out below;

New Code

Imports System.Web.SessionStateImports System.Web.RoutingPublic Class Global_asax    Inherits System.Web.HttpApplication    Sub Application_Start(ByVal sender As Object, ByVal e As EventArgs)        ' Fires when the application is started        RegisterRoutes(RouteTable.Routes)    End Sub    Sub Session_Start(ByVal sender As Object, ByVal e As EventArgs)        ' Fires when the session is started    End Sub    Sub Application_BeginRequest(ByVal sender As Object, ByVal e As EventArgs)        ' Fires at the beginning of each request    End Sub    Sub Application_AuthenticateRequest(ByVal sender As Object, ByVal e As EventArgs)        ' Fires upon attempting to authenticate the use    End Sub    Sub Application_Error(ByVal sender As Object, ByVal e As EventArgs)        ' Fires when an error occurs    End Sub    Sub Session_End(ByVal sender As Object, ByVal e As EventArgs)        ' Fires when the session ends    End Sub    Sub Application_End(ByVal sender As Object, ByVal e As EventArgs)        ' Fires when the application ends    End Sub    Sub RegisterRoutes(ByVal Routes As RouteCollection)
    End SubEnd Class
Copyright Claytabase Ltd 2020

Registered in England and Wales 08985867

Site Links

RSSLoginLink Cookie PolicySitemap

Social Media

facebook.com/Claytabaseinstagram.com/claytabase/twitter.com/Claytabaselinkedin.com/company/claytabase-ltd

Get in Touch

+15125961417info@claytabase.comClaytabase USA, 501 Congress Avenue, Suite 150, Austin, Texas, 78701, United States

Partnered With

The settings on this site are set to allow all cookies. These can be changed on our Cookie Policy & Settings page.
By continuing to use this site you agree to the use of cookies.
Ousia Logo
Logout
Ousia CMS Loader