Vous êtes sur la page 1sur 19

Group 3

Presentation
Databases

A database is a structured collection of records.


A database is a shared collection of related data used to support the activities of
a particular organization.
A database can be viewed as a repository of data that is defined once and then
accessed by various users.
A collection of interrelated tables
ADO.NET
Active Data Object
This is a software library in the .NET Framework consisting of software
components that provide data access services. It is designed to enable
developers to write managed codes for obtaining disconnected access data
sources. This feature of ADO.NET helps to create data sharing distributed
applications.
It is the technology used to interact with the database or data source.
It is used to open databases
Features of ADO .NET

Consistency can work with multiple data sources consistently thus providing
consistent access to data sources such as Ms SQL Server and any data sources
exposed via OLEDB. Includes inherent support for XML data sets
Powerful object model provides object model with database features
N-tier (involves developing separate levels of application) programming
presentation, business logic, data access and storage tier that work together to
provide a complete user experience
XML Support to access data in a standard way, XML serves to encode and format
data into a standards-complaint format. XML class framework enables you to cross
between the two libraries easily.
Disconnected Record Sets its major functionality is on disconnected data
Object model-Recreates all functionality present in database system
Steps to connect to a database
using VB.Net
After launching MS VB, select create object
Select Windows Form application from the templates and give a database name
Click on data on the menu bar and add new data source
In the data source toolbar, click and add new data sources
Select database from the configuration wizard and choose next.
Whilst in the wizard click new connection and select a data source
In the next window of the wizard browse your database file name
Select the tables you want to view and select finish and save the project
Select tools connect to database
Select a server name and the database name in the add connection dialog box
Click on the test connection button to check if the connection has succeeded
SQL Statements
Defining How Your Data Is Stored

CREATE DATABASE is used to create a new, empty database.


DROP DATABASE is used to completely destroy an existing database.
USE is used to select a default database.
CREATE TABLE is used to create a new table, which is where your data is actually
stored.
ALTER TABLE is used to modify an existing table's definition.
DROP TABLE is used to completely destroy an existing table.
DESCRIBE shows the structure of a table.
Manipulating Your Data

SELECT is used when you want to read (or select) your data.
INSERT is used when you want to add (or insert) new data.
UPDATE is used when you want to change (or update) existing data.
DELETE is used when you want to remove (or delete) existing data.
REPLACE is used when you want to add or change (or replace) new or existing
data.
TRUNCATE is used when you want to empty (or delete) all data from the
template
Transactions

START TRANSACTION is used to begin a transaction.


COMMIT is used to apply changes and end transaction.
ROLLBACK is used to discard changes and end transaction.
Example

CREATE DATABASE mydb;


USE mydb;
CREATE TABLE mytable ( id INT PRIMARY KEY, name VARCHAR(20) );
INSERT INTO mytable VALUES ( 1, 'Will' );
INSERT INTO mytable VALUES ( 2, 'Marry' );
INSERT INTO mytable VALUES ( 3, 'Dean' );
SELECT id, name FROM mytable WHERE id = 1;
UPDATE mytable SET name = 'Willy' WHERE id = 1;
SELECT id, name FROM mytable;
DELETE FROM mytable WHERE id = 1;
SELECT id, name FROM mytable;
DROP DATABASE mydb;
SELECT count(1) from mytable; gives the number of records in the table
Debugging
methodical process of finding and reducing the number
of bugs, or defects, in a computer program or a piece of
electronic hardware thus making it behave as expected

Tips on how to debug


an application
Step 1:Identify the error

This is an obvious step but a tricky one, sometimes a bad identification of an error can cause lots
of wasted developing time. It is usual that production errors reported by users are hard to be
interpreted and sometimes the information we are getting from them is misleading.
See the error. This is easy if you spot the error, it usually comes as a message or a pop up
message
Reproduce the error. You never should say that an error has been fixed if you were not able to
reproduce it.
Understand what the expected behaviour should be. In complex applications this could be hard
to tell what should be the expected behaviour of an error, but that knowledge is basic to be able
to fix the problem.
Validate the identification. Confirm with the responsible of the application that the error is
actually an error and that the expected behaviour is correct. The validation can also lead to
situations where it is not necessary or not worth it to fix the error.
Step 2: Find the error.

Once we have an error correctly identified, its time to go through the code to find the
exact spot where the error is located. A few techniques that may help to find an error are:
Logging. It can be to the console file which should help you to trace the error in the code.
Debugging. Debugging in the most technical sense of the word, meaning turning on
whatever the debugger you are using and stepping through the code.
Removing code. For example you could take out half of the code from the action causing
the machine to crash, and execute it hundreds of times, and if the application continues to
crash, do the same with the other half of the code, it MIGHT stop crushing, in that case we
can say that the error was on the first half if not you may keep splitting the code until you
find where the error is. It could be from a third party function.
Step 3:Analyze the error.

This is a critical step, use a bottom-up approach from the place the error was
found and analyse the code so you can see the big picture of the error,
analysing a bug has two main goals: to check that around that error there arent
any other errors to be found (the iceberg metaphor), and to make sure what are
the risks of entering any collateral damage in the fix.
Step 4: Prove your analysis

This is a straight forward step, after analysing the original bug you may have
come with a few more errors that may appear on the application, this step its
all about writing automated tests for these areas.
Once you have your tests, you can run them and you should see all them failing,
that proves that your analysis is right.
Step 5. Cover lateral damage.

At this stage you are almost ready to start coding the fix, but you have to
cover up before you change the code, so you create or gather (if already
created) all the unit tests for the code which is around where you will do
the changes so that you will be sure after completing the modification that
you wont have to break anything else. If you run this unit tests, they all
should pass.
Step 6. Fix the error

Thats it, finally you can fix the error!


Step 7. Validate the solution.

Run all the test scripts and check that they all pass.
Thank you !!!!!

Vous aimerez peut-être aussi