levo

Building a Desktop Solution with a Database

Connecting the application to the database

  • 3 things to know
  • A2 Unit 2
Start revising · £5/month

Overview

Connection in a database application, connection string and steps in using a connection.

What you need to know

Answer each one before you reveal it.

Your recallNot started
Key term

What is a connection in a database application?

Key term

Why should database credentials not be written into the source code?

Key term

Why must a connection be closed as soon as the work is done?

Questions from this subtopic

Each one with the model answer underneath.

  1. 1

    What is a connection in a database application?

    Model answer

    A connection is the open channel between the application and the database, established with the details of the server, the database name and the credentials, and used by every command the application issues.

  2. 2

    What is a connection string?

    Model answer

    A connection string is the single piece of configuration holding everything needed to reach the database: the provider, the server or file, the database name, and the authentication details.

  3. 3

    Why is a connection string held in configuration rather than written into the code?

    Model answer

    Because it differs between the development, test and live machines, and changing it should not require the application to be rebuilt. Holding it in one place also means it is changed once rather than everywhere it was copied.

  4. 4

    Why should database credentials not be written into the source code?

    Model answer

    Source code is copied, shared and often stored in version control, so credentials written into it are exposed to everyone with access to the code and cannot be changed without a rebuild.

  5. 5

    What are the steps in using a connection?

    Model answer

    The connection is created from the connection string, opened, used by one or more commands, and then closed, and it is closed in a construct that runs even if an error is raised part way through.

  6. 6

    Why must a connection be closed as soon as the work is done?

    Model answer

    A database allows a limited number of simultaneous connections and each holds resources on both machines, so connections left open eventually exhaust the pool and the application stops being able to reach the database at all.

Other ways to work this

The same content, four other ways.

Everything in your subscription

Runs, plus a mode for every other kind of session.

1Flash
2Imposter
3Fade
4Brain dump

Learn every subtopic in runs of four questions

Facts flash and fade, a wrong word hides in some of them, and a brain dump decides which questions are locked in.

Software and the Development Environment
Defining Data: Types, Variables and Classes
Program Control Structures
Objects, Classes and Data Structures

Cram the night before, weakest topic first

A quick scan finds your weakest topics. Recall each fact you missed three times in a row.

A null is the of one.
absencepresencetype

Blank Blitz consolidates the facts

Rapid timed gap-fills on the terms and numbers you need to recall without thinking.

✓What it iscovered
~Why it happenspartly there
How long it lastsnot there yet

Explain It tests your understanding

Explain a concept in your own words and see which of its points you covered.

An error is the mistake a person made.
TrueFalse

Test It catches misconceptions

Spot the fault in a statement. The faults are the mistakes students make most often.

721941163128510

Brain Breaks between sessions

Short focus games to reset attention, so the next set lands better than the last.

Every question in Building a Desktop Solution with a Database, on a schedule.

Learn it in runs of four questions, each ending on a brain dump against the clock. Every question you lock in comes back the next day, then at longer gaps, each time just before you would forget it.

Or £46 a year, about £3.83 a month. Cancel anytime.