The Institute of Finance Management
Faculty of Computing & Mathematics
Computer Science
Lecture 8
MS SQL Server is a database server
Product of Microsoft
Enables user to write queries and other SQL
statements and execute them
Consists of several features. A few are:
▪ Query Analyzer (improve the performance of the database)
▪ Profiler (analyze the overall performance of a database)
▪ Service Manager (tool used to manage services associated
with SQL Server)
▪ Bulk Copy Program (BCP) (command-line tool used to
import or export data)
SQL Server may run either on the same
computer or on another computer across a
network
Microsoft markets at least a dozen different
editions of Microsoft SQL Server, aimed at
different audiences and for workloads
ranging from small single-machine
applications to large Internet-facing
applications with many concurrent users.
2/12/2026
Some of the mainstream Edition
▪ SQL Server Enterprise Edition
▪ SQL Server Standard edition
▪ SQL Server Web Edition
▪ QL Server Workgroup Edition
▪ SQL Server Express Edition
SQL Server express edition is mostly used in
different activities
2/12/2026
SQL Server express edition is a powerful and
reliable free data management system that
deliver reliable data store for lightweight web
site and desktop applications.
It comprises a database specifically targeted
for embedded and smaller-scale applications.
2/12/2026
Maximum Memory Utilization (per instance
of SQL Server Database Engine)
▪ 1GB
▪ No matter how much RAM your system have,
SQL server express edition can just utilize 1 GB
Maximum Relational Database size
▪ 10GB
▪ The size of the Database can not grow more than
10GB
It is limited to use only one processor
How to install SQL server 2014 express
edition
Login in window machine as administer in
order to have administrative privileges which
will allows you to install and conducting
different settings
2/12/2026
Open google search Engine and type in
“Ms sql server 2014 express edition”
Go to MSN website with download link
instructions
Open Detail section
2/12/2026
Download two files
1. SQL Sever Database Engine
▪ Express Edition 32BIT or 64BIT, this depends on
your operating system
2. SQL Server 2014 Management studio
▪ 32BIT or 64BIT, this depends on your operating
system
2/12/2026
Database Engine is used to create online
relational database or online analytical
processing data.
This includes creating table for storing data
Database object such indexes, views and
stored
Procedures for viewing, managing and
securing data
2/12/2026
Open Download folder
Extract the downloaded SQL Sever Database
Engine File.
Once opened, the SQL Installation center will
open automatically, otherwise open the
extracted folder and double click on the
SETUP file
Follow the instruction to install the file
2/12/2026
In Database Engine Configuration
Authentication Mode
There are two types of authentication
▪ Window authentication
▪ Mixed Mode
Mixed Mode enables you to login by using
both methods
Specify password for the SQL server system
administrator (sa)
2/12/2026
• Open Download Folder
• Extract the File
• Once extracted, it will automatically launch
SQL server Installation center
• Install SQL Server Management Studio by
following instructions
2/12/2026
[Link] is a data access technology from
the Microsoft .NET Framework that provides
communication between relational and non-
relational systems through a common set of
components.
[Link] is a set of computer software components
that programmers can use to access data and data
services from a database.
ADO is an acronym for ActiveX Data Objects
2/12/2026
[Link] provides a common method for accessing
data stored in a variety of different formats using any
supported programming language.
For example, you can use [Link] to map data
stored in the following ways:
▪ In a SQL Server database
▪ In any format accessible using the Object Linking and
Embedding, Database (OLE DB) application programming
interface (API)
▪ In any format accessible using the Open Database
Connectivity (ODBC) API
▪ In an Oracle database.
2/12/2026
• [Link] components provide the necessary
classes that enable connection to data store,
retrieve, manipulate, and update data.
• [Link] supports two types of models
• Disconnected Model
• Connection Oriented Model
• [Link] is designed to provide a Disconnected
Architecture.
✓ This means that applications connect to the database
to retrieve a load of data and store it in memory.
✓ Then it disconnect from the database and manipulate
the in-memory copy of the data.
• If the database needs to be updated with changes
made to the in-memory copy, a new connection is
established and the database is updated.
• The connection between application and database
is not always maintained
2/12/2026
Data Set
[Link]
Application Data View
DB
Disconnected Model
Data Adapter Connection
Data Providers
2/12/2026
Update
Applicati
on Data Data
Set Adapter
Fill
• Data Adapter includes
• Select Command
• Table mapping
• Insert Command
• Update Command
• Delete Command
2/12/2026
• [Link] is conceptually divided into two
groups
✓ Consumers (applications that need access to
the data)
✓ Data providers (software components that
implement the interface and thereby provide
the data to the consumer)
2/12/2026
Data consumers are the applications that
need access to data in order to perform their
purpose.
Data consumers are things like web
application, mobile apps, and desktop
applications.
2/12/2026
Data providers are the data sources that
contain the data the applications needs to
access.
Data providers include relational databases,
spreadsheets, access databases and many
other data sources.
2/12/2026
2/12/2026
Allows your application to scale up
This means database will perform just as well
supporting hundreds of users as it does supporting
ten users
This is because the application connects to the
database only long enough to retrieve or update data,
thereby freeing available database connections for
other instances of your application or other
applications using the same database
• [Link] offers a number of connection
objects such as OleDbConnection
and SqlConnection.
✓ OleDbConnection is used to access OLEDB (API) data
such as Microsoft Access
✓ SqlConnection is used to access data provided by
Microsoft SQL Server.
• Since we will work with SQL database in our example,
we will use the SqlConnection object.
The core [Link] classes exist in the [Link]
namespace
This namespace, in turn, contains some child
namespaces
▪ [Link] provides classes for
accessing SQL Server databases
▪ [Link] provides classes for OLE
(Object Linking and Embedding) DB–compliant
databases, respectively.
Note: Namespace is a way of encapsulating items
To use core [Link] classes, such as DataSet and
DataView, without typing the full name, you must
import the [Link] namespace, as shown
below:
Imports [Link]
To qualify in using members of the SqlClient
namespace. Use the keyword import
Imports [Link]
• [Link] contains four main classes from the
[Link] namespace that are used to
establish connection:
1. SqlConnection
2. SqlCommand
3. SqlDataAdapter
4. SqlDataReader
• Different three terms are used in execution of
SQL commands
1. DataAdapter is used to execute SQL
statements (command)and is used to
populate the results of SQL Query into a
DataSet or DataTable
2. DataSet is in simple terms set of Data i.e.
set of DataTables or collection of
DataTables i.e. it can hold one or multiple
DataTables.
3. DataReader as the name suggests reads
data. DataReader is used for fetching
records from the SQL Query or Stored
Procedure
• DataReader is an alternative to a DataSet
that uses fewer system resources but
provides far less flexibility.
2/12/2026
2/12/2026
• The SqlConnection Class provides a connection to an
SQL Server database
• When establishing connection to your database, you
can choose to specify a connection string as a
parameter.
• The connection string contains all the information
required to open a connection to your database
• Connection String Parameters
– Server
– Database
– User ID
– Password
• To see how these parameters function in a connection
string when initialize a connection object, consider the
following code fragment.
• It uses the SqlConnection class to initialize a
connection object that uses a specific user ID and
password in the connection string:
Dim objConnection As SqlConnection = New SqlConnection
("Server=localhost\WROX; Database=pubs; UserID=sa; Password=wrox;")
• The created object objConnection can be used with
different methods
• After you initialize a connection object with a
connection string, you can invoke the methods of
the SqlConnection object such as Open and Close,
which actually open and close a connection to the
database specified in the connection string.
‘ Open the database connection..
[Link]()
’ Close the database connection..
[Link]()
• The SqlCommand class represents an SQL command to
execute against a data store.
• The command is usually a select, insert, update, or
delete query, and can be an SQL string or a call to a
stored procedure.
• The constructor for the SqlCommand class must be
initialized
• After the object has been initialized, you can set the
properties you need to perform
Dim objCommand As SqlCommand = New SqlCommand()
• Certain properties must be set on the SqlCommand
object before you can execute the query.
• The first of these properties is Connection.
• This property is set to a SqlConnection object
[Link] = objConnection
• For the command to execute successfully, the
connection must be open at the time of execution.
• The next property that must be set is the CommandText
property. This property specifies the SQL string or stored
procedure to be executed.
Dim objConnection As SqlConnection = New _
SqlConnection("server=(local);database=pubs;user id=sa;password=")
Dim objCommand As SqlCommand = New SqlCommand()
[Link] = objConnection
[Link] = "INSERT INTO authors " & _
"(au_id, au_lname, au_fname, contract) " & _
"VALUES(’123-45-6789’, ‘Barnes’, ‘David’, 1)"
The DataAdapter serves as a bridge between
your database and your program
It is used to execute a Command object to
retrieve data from the database and then fill a
DataSet or DataTable object.
It is also used to insert, update, or delete data in
the database from a DataSet or DataTable
object
2/12/2026
When you want to read data from the data store,
you must set the SelectCommand property of the
SqlDataAdapter class first.
This property is an SqlCommand object and is
used to specify what data to select and how to
select that data.
Therefore, the SelectCommand property has
properties of its own, and you need to set them
just as you would set properties on a normal
SQLCommand.
• In order to retrieve data from database and
populate the DataTable, DataAdapter and
DataTable must be initialized
• Then populate DataTable by using Fill Method
• After the DataTable has been populated the job
of DataAdapter has been done
• Call Dispose method to release resources held
by DataAdapter and set as Nothing
• The job of Command object is also done so it
could be wise to dispose and set it to nothing in
order to release the resource and free up the
memory
’ Declare SqlDataAdapter object..
Dim objDataAdapter As New SqlDataAdapter()
’ Assign a new SqlCommand to the SelectCommand property
[Link] = New SqlCommand()
’ Set the SelectCommand properties..
[Link] = objConnection
[Link] = _
"SELECT lname, fname FROM authors ORDER BY lname, fname"
‘create the object dataset
Dim objDataSet as DataSet = New DataSet()
‘Fill the DataSet with data
[Link] (objDataSet, lname, fname )
2/12/2026
‘Set the DataAdapter to nothing to release resources
[Link]()
objDataAdapter = Nothing
‘set the command object nothing to release resources
[Link]()
objCommand = Nothing
• DataReader object is used only to read data
from your database
• Since DataReader reads data from
Database, it holds an open connection to the
database
• Thus, the Connection object that the
DataReader object is using will be busy
serving up the data to the DataReader and
cannot be used for any other database
operations.
2/12/2026
The DataReader class does not use a
constructor to be initialized
Rather, it uses the ExecuteReader method of
a Command object.
Because it assumes that you have already
initialized a Command object with the SQL
statements to be executed and that the
database connection is open
2/12/2026
After all records have been read, it is important to
close the DataReader using the Close method.
This releases all resources held by the DataReader
and allows the open database connection to be used
for another operation or to be closed.
You should set it to Nothing to free the memory
being held by this object.
You should also close your database connection if it
is no longer needed
Dim objReader As OleDbDataReader =
[Link]()
While [Link]
[Link]([Link](“FIRST_NAME”) & “
“ & [Link](“LAST_NAME”))
End While
[Link]()
[Link]()
objReader = Nothing
END
2/12/2026