levo

Building a Desktop Solution with a Database

Connecting the application to the database

  • 3 things to know
  • A2 Unit 2

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.

What is inside Levo

Six ways to work the same material.

1Closed book
2Open book
3Closed book

The 3-step method, run for you

Answer cold, learn it, then prove it stuck. Levo tracks the jump between your first attempt and your last.

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

Cram a whole paper in one sitting

Sort every topic into what you know and what you do not, then drill only the weak ones.

A null is the of one.
absencepresencetype

Blank Blitz makes facts automatic

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

AA null means no value has been recorded.
BZero and an empty string are values.
CA null is the absence of a value.

Build It gets the exam shape right

Assemble a full-mark answer from its marking points, in the order an examiner wants them.

An error is the mistake a person made.
TrueFalse

Test It catches misconceptions

Spot the fault in a statement. The traps are the mistakes students actually make.

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.

Attempt a question from memory, write the correct version, then attempt it again. Levo records the jump between your first attempt and your last, and brings each question back on the day you are due to forget it.

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