The document is a lab manual for the subject GUI and Database Management in the Department of Information Technology at K. J. Somaiya Institute of Engineering & Information Technology. It outlines 10 experiments involving entity relationship modeling, implementing a database using SQL Server, modifying the database schema, implementing simple and advanced SQL queries, joins, views, designing a graphical user interface using VB 6.0, connecting the GUI to a database, and developing a working module. The experiments aim to teach students how to design databases, implement them, query and manipulate data, and connect a user interface.
A Critique of the Proposed National Education Policy Reform
K.J. Somaiya Institute of Engineering and Information Technology Lab Manual
1. K. J. Somaiya Institute of Engineering & Information Technology
K. J. Somaiya Institute of Engineering
And
Information Technology
Sion, Mumbai - 22
Department: Information Technology
Academic year: 2011-12
Lab Manual
Class - SE Sem - III
SUBJECT: GUI AND DATABASE
MANAGEMENT
Version: 2
Department of Information Technology/GUI & DBM(Sem: III) Page 1
2. K. J. Somaiya Institute of Engineering & Information Technology
K.J.SOMAIYA INSTITUTE OF ENGINEERING AND
INFORMATION TECHNOLOGY
DEPARTMENT OF INFORMATION TECHNOLOGY
CLASS: S.E. SEMESTER: III
SUBJECT: GUI AND DATABASE MANAGEMENT
_____________________________________________________________________
List of Experiments
1. ER model and reduction of ER model to relational model.
2. Implementation of database using SQL server
3. Modification of database schema
4. Implementation simple SQL queries
5. Implementation of advanced SQL queries
6. Implementation of Joins
7. Implementation of Views
8. Layout of GUI & Study of various controls used in VB 6.0
9. Implementation of GUI using VB 6.0, Business logic development
10. Database connectivity and working module
Seema Yadav
Subject Incharge
Department of Information Technology/GUI & DBM(Sem: III) Page 2
3. K. J. Somaiya Institute of Engineering & Information Technology
Experiment No:1
Aim: ER model and reduction of ER model to relational model.
Software used: MS word.
Theory : Entity relationship model is a data model which represent the overall logical structure of
database and it is very useful in mapping the meanings and interactions of real world enterprises
onto a conceptual schema.
The E-R model employs three basic notations:
Entity sets: An entity set is a set of entities of the same type that share the same properties .(an
entity is a real world object)
Relationship sets: Relationship set is a set of relationships of the same type.(relationship is an
association among several entities)
Attributes: Attributes are properties of entity set used to describe it.
Different types of attributes are as follows:
1. Simple and composite attributes. In our examples thus far, the attributes have been simple;
that is, they are not divided into subparts. Composite attributes,on the other hand, can be divided
into subparts (that is, other attributes). For example, an attribute name could be structured as a
composite attribute consistingof first-name, middle-initial, and last-name. Using composite
attributes in a design schema is a good choice if a user will wish to refer to an entire attribute on
some occasions, and to only a component of the attribute on other occasions. Suppose we were to
substitute for the customer entity-set attributes customer-street and customer-city the composite
attribute address with the attributes
street, city, state, and zip-code.2 Composite attributes help us to group
together related attributes, making the modeling cleaner
2. Single-valued and multivalued attributes. The attributes in our examples all have a single value
for a particular entity. For instance, the loan-number attribute for a specific loan entity refers to
only one loan number. Such attributes are said to be single valued. There may be instances where
an attribute has a set of values for a specific entity. Consider an employee entity set with the
attribute phone-number. An employee may have zero, one, or several phone numbers, and
different employees may have different numbers of phones. This type of attribute is said to be
multivalued.
3. Derived attribute. The value for this type of attribute can be derived from the values of other
related attributes or entities. For instance, let us say that the customer entity set has an attribute
loans-held, which represents how many loans a customer has from the bank. We can derive the
value for this attribute by counting the number of loan
Department of Information Technology/GUI & DBM(Sem: III) Page 3
4. K. J. Somaiya Institute of Engineering & Information Technology
entities associated with that customer. As another example, suppose that the customer entity set
has an attribute age, which indicates the customer’s age. If the customer entity set also has an
attribute date-of-birth, we can calculate age from date-of-birth and the current date. Thus, age is a
derived attribute. In this case, date-of-birth may be referred to as a base attribute, or a stored
attribute. The value of a derived attribute is not stored, but is computed when required.
In extended E R model we have three additional concepts:
Specialization: The process of designating the subgroupings within an entity set is called
specialization( finding specialized attributes)
e.g. in entity set person we have two types of entities like customer and employee. Both are
person but employee have specialized attribute salary and customer have rating.
Generalization: It is a top down design process in which multiple entity sets are synthesized into
a higher level entirty set on the basis of common features.
e.g. customer entity set and employee entity set both have common attributes like name, address,
age which can be used as attributes of higher level entity set person.
Aggregation : it is an abstraction through which relationships are treated as higher level entities.
The most important use of the E-R diagram is it represents some constraints like total and partial
praticiplation , one to one, many to many, many to one, one to many mapping etc.
Department of Information Technology/GUI & DBM(Sem: III) Page 4
5. K. J. Somaiya Institute of Engineering & Information Technology
Symbols used in E R diagram:
E
Entity set A Attribute
E A
Multivalued attribute
Weak entity set
A
R Derived attribute
Relationship set
A
Primary key
A
R Partial key
Identitying
relationship set
Composite Attribute
Many to one cardinality
A
R
Total participation
One to many cardinality R
R
Partial participation
R
One to one cardinality
R Specialization or generalization
many to many cardinality
ISA
R
Department of Information Technology/GUI & DBM(Sem: III) Page 5
6. K. J. Somaiya Institute of Engineering & Information Technology
Reducing ER model into relational model.
1) Any strong entity set E having attributes a1, a2,…,an is reduced into a relation schema
called E with n distinct attributes i.e. a separate relation with name E and n distinct
coloumns.
2) Any weak entity set A having attrinutes a1, a2,..n and a strong entity set B on which A
depends, having primary key attributes as b1, b2, …, bn is reduced into a relation
schema called A with one attribute for each member of set
{ a1, a2,…, an} U {b1, b2, ……. , bm}
3) Any relationship set R having a1,a2,…,an as a set of attributes formed by union of the
primary keys of each of the entity sets participating in R and b1, b2,….,bm as set of
descriptive attributes is reduced into a relation schema called R with one attribute for
each member of the set
{a1, a2, …. ,an} U {b1, b2, …., bn}
Primary key of relationship set is decided as follows
For binary many to many relationships the union of primary key attributes from the
participating entity sets is primary ey.
For binary one to one relationship set the primary key of either of the participating entity
set can be chosen as the primary key.
For binary many to one or one to many relationship set the primary key of the entity set on
the many side of the relationship set serves as the primary key.
For n-ary relationship sets without any arrows on its edges, union of the primary key
attributes of participating entity sets is a primary key.
For n-ary relationship sets with an arrows on one of its edges, union of the primary key
attributes of participating entity sets is a primary key.
To remove redundancy we generally make separate relation schema for many to many
relationship set with primary key and other attributes as mentioned above.
For one to one we combine relation schema of relationship set with relation schema of
either sides of entity sets relation schema.
For one to many and many to one we combine relation schema of relationship set with
relation schema of entity set on many side entity set.
We don’t make separate relation schema for identifying relationship set.
Department of Information Technology/GUI & DBM(Sem: III) Page 6
7. K. J. Somaiya Institute of Engineering & Information Technology
Every composite attribute A having subparts a1, a2,…,an is represented by separate
column for each subpart in relation schema of the associated entity set.
For multivalued attribute separate schema is form having columns as attributes of primary
key of associated entity set and a column for multivalued attribute
For disjoint generalization/specialization create separate relation schemas only for every
lower level entity set(higher level entity set’s attributes are inherited so add columns for
same) and not for higher level entity set.
For overlapping generatlization/specialization create separate relation schemas for higher
level as well as lower level entity sets.
Also include the foreign key constraint in lower level entity set for the primary key
attributes of higher level entity set.
No separate relation is required to represent the aggregation the relation created from the
defining relationship is used instead
(design schema for relationship set treated as entity set carefully)
Conclusion:
Hence we have studied the ER data model consisting of a set of basic objects called
entities & relations among those objects.It is intended primarily for database design process by
following the specification.
Reference book: Database System and concepts
Author: Henry F.Korth,Sliberchartz ,Sudarshan
Publication: Tata McGraw Hill
Department of Information Technology/GUI & DBM(Sem: III) Page 7
8. K. J. Somaiya Institute of Engineering & Information Technology
Department of Information Technology/GUI & DBM(Sem: III) Page 8
9. K. J. Somaiya Institute of Engineering & Information Technology
Experiment No:- 2
Aim : To implement the database using relational model design in experiment 1 .
Creation of Database with proper constraints( Pk, Fk etc).
Data Insertion into Database using insert statement(at least 5 records per table).
Applying different constraints- check , unique, not null etc.
Drop table.
Resources Used : Windows Xp professional, MY SQL .
Theory : After design of relational schema next step is to implement the database on machine
using Ms. SQL Server 2000.
Implemention can be done using SQL queries or enterprise manager.
Implementation Using Queries:
To create database use query.
create database database_name;
Now database is created successfully . To use it use query
use database_name;
To create relation in this database use query
create table table_name(
attribute_name 1 domain,
attribute_name 2 domain,
attribute_name 3 domain [not null],
.
.
.
attribute_name n domain,
[ constr_pk1:
primary key( list of required and above defined attributes),]
[constr_fk1:
foreign key (attribute_name) references referenced_table_name,]
[constr_ck1;
check( attribute_name comparison_operator constant),]
[constr_ck2:
Department of Information Technology/GUI & DBM(Sem: III) Page 9
10. K. J. Somaiya Institute of Engineering & Information Technology
check(attribute_name in (list of string or numeric constants),]
[constr_uq1:
unique(attribute_name)]
);
Various Domains available are;
char(n) for a string with exactly n characters
varchar(n) for a string with n or less than n characters
int for integer values
datetime for date and time related values ( ‘mm/dd/yyyy hh:mm:ss’ )
Now relation/table is created(empty initially). To populate relation with tuples use
insert into relation_name values( attribute_name1_value,
attribute_name1_value,…………………,attribute_name _value);
*put string values in single quotes
Conclusion: In this experiment concepts of various integrity constraints and DDL for creation of
new relation is studied. Using it a database is implemented actually.
Reference book: Database System and concepts
Author: Henry F.Korth,Sliberchartz ,Sudarshan
Publication: Tata McGraw Hill
Program :
Output:
Department of Information Technology/GUI & DBM(Sem: III) Page 10
11. K. J. Somaiya Institute of Engineering & Information Technology
Experiment No:- 3
Aim : To modify Data Definition (schema) of the database created.
1) Add column, remove column using alter table query
2) Show schema of any table(SP-help).
3) Add constraint, drop constraint explicitly(like check , unique, not null etc.)
using alter table query
Resources Used : Windows Xp professional, MY SQL.
Theory : Once the database design is finalized and database is implement actually we alter
schema of the database infrequently or never. According to changes in the requirements of the
database users we may need to change schema.
Change in database schema mainly includes addition of new attributes to existing relation schema
or deletion of the existing attributes of the relation schema. Sometimes we need to include some
addition constraints on relation or may need to remove some existing constraints
To see whether these changes are reflected in database schema we can use command SP_help
relation_name.
This command gives details of the specified relation.
Alter command is used to add column , remove column, add constraint and remove constraints.
To add new column(attribute) A to relation R
alter table R add A domaintype;
As a result of this query a new column with name A is added to relation R with null values for
existing tuples in relation R for newly added column.
To remove existing column A from relation R
alter table R drop column A;
Column A as a whole will be deleted from relation R.
To add new constraint with name C1 to relation R
alter table R add constraint C1 description_of_constraint;
To drop existing constraint C1
alter table R drop constraint C1;
Conclusion: Once designed , database schema changes infrequently. In case change is required
then we can use above DDL command to alter it.
Department of Information Technology/GUI & DBM(Sem: III) Page 11
12. K. J. Somaiya Institute of Engineering & Information Technology
Reference book: Database System and concepts
Author: Henry F.Korth,Sliberchartz ,Sudarshan
Publication: Tata McGraw Hill
Program:
Output:
Department of Information Technology/GUI & DBM(Sem: III) Page 12
13. K. J. Somaiya Institute of Engineering & Information Technology
Experiment No:- 4
Aim : To implement simple SQL queries( Single table retrieval )
Make use of different operators (relational, logical etc)
Selection of rows, columns, renaming columns, use of distinct keyword
String Handling(%, - , like)
Resources Used : Windows Xp professional, MY SQL
Theory : After the database is populated with data next is data manipulation which includes
mainly retriving and modifying the data in database.
We can retrive one or more columns from relation. Also we can rename the columns in the
relation. Based on specific condition we can retrive set of rows from relation.
Basic structure of simple SQL query is.
select A1,A2,…….., An from R
where P
In select clause we list required column names. If we need all columns in relation then use just *
(i.e. select * from R where P).
In from clause we just list relation names from which we are selecting attributes mentioned in
select clause.
In where clause we mention the predicate which is tested on every tuple of relations specified in
from clause.
For generating simple predicate we use names of the attributes and the relational operators like < ,
> , =, <= , >= etc. and to generate the complex predicate we use logical operators as connective
like and , or with simple predicates.
Renaming attributes using as clause
In the select clause we can rename one or more attributes using as clause.
select A1 , A2 as new_namea3, A3,A4 as new_namea4 from R where P
Keyword distinct
distinct keyword is used to eliminate duplicate values in resultant relation
select distinct attribute_name from R
string operations using like operator
In this a pattern generated using two special characters % and _ is used with like operator
Department of Information Technology/GUI & DBM(Sem: III) Page 13
14. K. J. Somaiya Institute of Engineering & Information Technology
select * from employee where fname like C%
Upadating database:
We can update a specific attributes value for specific or all tuples using update clause.
alter table R set fname=’jone’ where ssn=’emp0001’
for conditional update we can use case update
update R set salary=
when salary>10000 then
salary*1.06
else
salary*1.05
end
Conclusion: In this program various single table retrival queries are executed on relations of
company database. Use of various operators present is SQL is studied.
Reference book: Database System and concepts
Author: Henry F.Korth,Sliberchartz ,Sudarshan
Publication: Tata McGraw Hill
Program:
Output :
Department of Information Technology/GUI & DBM(Sem: III) Page 14
15. K. J. Somaiya Institute of Engineering & Information Technology
Experiment No:- 5
Aim : To write advanced queries in SQL using
Group by, having clause, aggregate functions like sum, max, min, avg, count.
Set operations like union, union all, order by clause etc.
Nested queries using not in, in, not exists, exists, any, all etc.
Resources Used : Windows Xp professional, Ms. SQL Server 2000
Theory : We can write advanced queries in SQL using the various constructs like union, order
by, not in, not exists, exists, max, min, having clause.
Union and union all operation:
This operation combines the result of two or more queries into a single result set consisting of all
the rows belonging to all queries in the union.
Syntax:
Select a1, a2, a3, ……….,an from R1 union select b1, b2, b3,………,bn from R2
R1 and R2 are two compatible relations. Compatibility here means arity of both the relations is
same and also domain of ai must match with domain of bi for i=1, 2,3,……..n.
In union operation all the duplicates are eliminated and if we want to retain the duplicates the use
union all in place of union.
Order by clause:
Order by clause is used to sort the tuples in given relation in either ascending or descending order
based on the value of one or more attributes present in that relation. The default order is
ascending order. If we want to sort relation in descending order use keyword desc(use keyword
asc explicitly to sort relation in ascending order ).
Syntax:
Select a1, a2, ……..,an from R order by a2 desc;
Select a1, a2, ……,an from R order by a1 [asc];
Select a1, a2,……..,an from R order by a1 asc a2 desc;
In third example tuples in R are sorted in ascding order of values of a1. If two or more tuples
have same value for a1 then the are sorted in descing order of value of a2.
Group by clause:
Group by clause is used to group the rows of the relation based on a certain condition.Group by is
usually used in conjuction with the aggregate functions like sum, ag, min, max etc.
For example one can group the rows in book relation based on the authors name.
Select book_name, price, subject from book group by author.
Department of Information Technology/GUI & DBM(Sem: III) Page 15
16. K. J. Somaiya Institute of Engineering & Information Technology
Having clause:
Having clause tells SQL to include only certain groups produced by the group by caluse in the
query result set. Having clause is equivalent to the where clause and is used to sqecity the search
criteria or search condition where group by clause is specified.
For example to select the names of the author who has written more than 3 books from book
relation.
Select author from book group by author having count(book-id) >3;
Aggregate functions:
Aggregate functions are the functions that take a collection of values as input and returns a single
value. SQL offers five bullt in aggregate functions.
Average:
avg([distinct | all] n)
returns average values of n, ignoring all null values.
Minimum:
min ([distinct | all] n)
returns minimum value of n.
Maximum:
max([distinct | all] n)
returns a maximum value of n
Total:
sum([distinct | all] n)
return sum of all values of n.
count:
count([distinct | all] n)
returns the number of rowes where n is not null.
Nested subqueries:
in:
The in connective tests for the set membership, where the set is a collection of values produced by
a select clause.
For example to select details of the books written by r.p.jain and d.perry use
select book_id, book_name,price from book where author in(‘r.p.jain’, ‘d. perry’,’godse’);
not in:
This connective tests for absence of the set membership.
For example to select details of the books written by authors other than r.p.jain and d.perry use
select book_id, book_name,price from book where author not in(‘r.p.jain’, ‘d. perry’,’godse’);
Department of Information Technology/GUI & DBM(Sem: III) Page 16
17. K. J. Somaiya Institute of Engineering & Information Technology
all:
this keyword is basically used in set comparison query.
It is used in association with relational operators.
“> all” corresponds to the phrase ‘greater than all’.
For example to display details of the book that have price greater than all the books published in
year 2000 use.
Select book_id, book_name, price from book where price >all (select price from book where
pub_year=’2000’);
any or some:
These keywords are used with relational operators in where clause of set comparison query.
“=some” is identical to in and “<>some” is identical to not in.
“>any “ is nothing but ‘greater than at least one’.
exists and not exists:
exists is the test for non empty set. It is represented by an expression of the form ‘exists (select
……. From …….) ‘. Such expression evaluates to true only if the result evaluating the sub query
represented by the (select ……. From ……) is non empty.
for example to select names of the books for which order is placed use
select book_name from book where exists( select * from order where
book.book_id=order.book_id);
not exists tests for empty set. For this the subquery must return empty set.
Conclusion: In many cases data is needed to be obtained from more than one relations based on
certain conditions that time we can use advanced queries.
Reference book: Database System and concepts
Author: Henry F.Korth,Sliberchartz ,Sudarshan
Publication: Tata McGraw Hill
Program :
Output :
Department of Information Technology/GUI & DBM(Sem: III) Page 17
18. K. J. Somaiya Institute of Engineering & Information Technology
Experiment No: 6
Aim: To implement Joins.
Software required: MYSQL/SQL server/Oracle
Theory:
Introduction to joins
A join can be defined as an operation that includes retrieval of data from more than one table
at a time.A join is a query that combines columns from two or more sources. Effectively you are
reversing non less decomposition process used to normalize the database pulling related data back
together in a combined result.
Technically you can only join two sources ,such as two tables.When you need to join more
sources you can do it in by joining two tables and then join the result with the the third table and
so on.
1) Inner Join: Data from multiple table is displayed after comparing values present in common
column.
Eg: select spname,custname from salesreps join customer on(salesreps.spnum =
customer.spnum)
2) Outer Join:result contains all rows from one table and matching rows from another table.
Eg: select spname,custname from salesreps left outer join customer on (salesreps.spnum =
customer.spnum)
In this query ,rows from salesreps table are returned whether or not they qualify. This is
because we specify left outer join.
The left is in reference to join and salesreps table is or left side of equality operator.Thes are
matched to NULL values for columns in right ( customer) table.
If you execute this as right outer join,difference is that unqualified rows in the right (if any)
would be returned by query.
3) Equi Join: It displays redundant columns data in result set where two or more tables are compared
for equality.
Eg:select emp.name as employeename,mgr.name as managername from employee emp
join employeemgr where emp.managerno = mgr.managerno;
Conclusion: Thus we have implemented joins in SQL and studied that join operation take two
relations and returns another relation as result. Inner join, outer join, equi join and self join are
various types of joins.
Department of Information Technology/GUI & DBM(Sem: III) Page 18
19. K. J. Somaiya Institute of Engineering & Information Technology
Reference book: Database System and concepts
Author: Henry F.Korth,Sliberchartz ,Sudarshan
Publication: Tata McGraw Hill
Output:
Department of Information Technology/GUI & DBM(Sem: III) Page 19
20. K. J. Somaiya Institute of Engineering & Information Technology
Experiment No: 7
Aim: Implementing Views
Software Required : MYSQL,ORACLE or SQL Server
Theory:
Introduction to views:
SQL introduced concept of views as a means of providing a user with a personalized model of
database.
A view can hide data that a user does not need to see.The ability of views to hide data serves
both to simplify usage because they restrict system and to hence enhance security.
Views simplify system usage because they restrict user attention to data of interest.Although a
user may be denied access to a relation that user may be allowed to access part of that relation
through a view.
Thus combination of relational level security and view-level security limits user’s access to
precisely data that user needs.
1) Creating Views:
A view can be created using create view statement.
Eg.A clerk need to know names of all customers who have a loan at each branch.This clerk is
not authorized to see information regarding specific loans that customer may have.
Create view cust_loan as
(select branch_name,customer_name
From borrower,loan
Where borrower.loan_number=loan.loan_number)
2) Altering views:
A view can be altered using alter view statement.
Eg. Update employee set target =600000 where city =’newyork’;
Select * from employee;
3) Dropping view:
A view can be dropped from database using drop view statement.
Eg. Drop view student;
Select * from student;
Table:student does not exist.
4) Modifying data through views:
It is possible to modify data in base table by modyfying data in view.
Creation of view does not require resource authorization.A user who creates a vie w
does not necessarily receive all priviliges on that view.He receives only those
privileges that provide no additional authorization beyond those he already had.
Department of Information Technology/GUI & DBM(Sem: III) Page 20
21. K. J. Somaiya Institute of Engineering & Information Technology
Conclusion: A view is a critcal table which gives access to a subset of columnns from one
or more tables.Various operations can be performed over views like creating
views,modifying data using views,altering views and dropping views.Views are means for
security of database.
Reference book: Database System and concepts
Author: Henry F.Korth,Sliberchartz ,Sudarshan
Publication: Tata McGraw Hill
Output:
Department of Information Technology/GUI & DBM(Sem: III) Page 21
22. K. J. Somaiya Institute of Engineering & Information Technology
Experiment No:- 8
Aim : To design layout for forms required in the application and to study various controls in VB.
Resources Used : Windows Xp professional, MS world.
Theory : In a company database we need to create forms for all the master tables and many to
many relationship related tables.
We need to insert, delete and update, search data in these relations. So we need to create a form
which have labeled controls for various attributes of the relation .
Generally to accept input from user textbox is preferred and for predefined values listbox or
combobox is preferred
Employee form:
Employee fname: lable and textbox
Employee mname: lable and textbox
Employee lname: label and textbox
SSN : textbox
City: textbox
Salary : textbox
Department number: listbox
New : command button
Save : command button
Delete : command button
Search : command button
Display : command button
Along with these we need proper labels to describe these fields so that user will come to know in
which field which data is to be entered.
Department form
Department name: textbox
Department number: textbox
Department location:textbox
Algorithm / Activity Diagram:
New : command button
Save : command button
Delete : command button
Search : command button
Display : command button
Department of Information Technology/GUI & DBM(Sem: III) Page 22
23. K. J. Somaiya Institute of Engineering & Information Technology
Works on form
SSN: listbox
Project number :listbox
Number of hrs: textbox
Save : command button
Delete : command button
Search : command button
Display : command button
Project form
Project number: textbox
Project name: textbox
Project location: textbox
Department number:listbox
New : command button
Save : command button
Delete : command button
Search : command button
Display : command button
A control is an object that can be frawn on a form to enhance user interaction with the application.
They respond to events initiated by the user or triggered by the system. Controls in VB are
divided in to
1) intrinsic controls;
Control description
Label Displays text on a form(read only text)
Frame Serves as a container for other controls
Checkbox Enables users to select or deselect an option
Combobox Allows users to select from a list of items or
add a new value
Hscrollbar Allows users to scroll horixontally through a
list of data in another control
Timer Lets your program perform actions in real time,
without user interaction
DirlList box Enables users to select a directory or folder
Shape Displays a shape on a form
Image Diaplays graphics on a form but cant be a
container
Picturebox Displays graphics on a form and can serve as a
container
Department of Information Technology/GUI & DBM(Sem: III) Page 23
24. K. J. Somaiya Institute of Engineering & Information Technology
Command button Enables users to initiate actions
Option button Lets users select one choice from a group; must
be used in groups o f tow or more
List box Enables users to select from a list items
Vscrollbar Enables users to select from a list of items
Drive list box Lets users select a disk drive
Line Displays a line on a form
Data Lets your program connect to database
File list box Lets users select a file
2) Active X controls
Control Description
MSFlexGird For displaying contents of relations on form
ADO Data control Required for database connectivity
All above controls have many properties which can be set by designer to make GUI attractive and
effective.
Among these name and caption are two important properties.
Name property take the name for control which is used in coding and caption value of control is
displayed on the form.
Conclusion: In this based on the requirements of the application form design is done. Various
fields and operations using the form are decided. Various controls available in visual basic are
studied.
Reference book:Visual Basic 6 programming Black Book
Author:Steven Holzner
Publication:Dreamtech
Program :
How many forms will be there and what all fields will be there in each form is decided and
various operations to be done are also decided.
Output :
Rough sketches of the forms.
Department of Information Technology/GUI & DBM(Sem: III) Page 24
25. K. J. Somaiya Institute of Engineering & Information Technology
Experiment No:- 9
Aim : To implement various forms required for application using VB 6.0 applying GUI design
concepts to it , business logic development and study of various coding constructs for
applications.
Resources Used : VB 6.0, Microsoft Windows Xp professional.
Theory : A graphical user interface is a type of user interface using graphics for interaction with a
computer or other media formats which employs graphical images, widgets along with text to
represent the information and actions available to a user. Actions are performed through direct
manipulation of graphical elements(e.g clicking the command button). We must be very clear
about the colour selections, placement of graphical elements. We should take care that graphical
elements used in interface communicate correct meaning to user.
Visual basic is a true graphical development environment. It allows programmers to quickly
develop powerful Windows applications. It has the ability to develop programs that can be used a
a front end application to a database system, serving as the user interface which collects user input
and displays formatted output in a more appealing and useful form. As programmer works in the
graphical environment much of the program code is automatically generated by the Visual basic
program.
Developing applications with VB is three step approach:
1) design the appearance of the application(i.e form design by drag and drop controls in tool
box of visual basic editor)
2) assign property settings to the objects of the program
3) write code to direct specific tasks at runtime
We use Visual Basic 6.0 as event driven programming for developing code for business logic.
Actually, while programming in Visual Basic, it must first be decided how the application
interacts with the user. In other words, it must be decided how each control reacts to user actions,
such as the click of a mouse, keystrokes and so on and these reactions must be programmed. This
is called Event driven programming because the application does not determine the flow, instead,
the events caused by the user determine the flow of the application.
Various object in VB are various controls in the form. With every object some predefined events
are associated. And for every event event handler function is provided in which write code about
action to be taken for that event.
To effectively control the VB program flow we use various control statements listed below
1) If...Then...Else statement is used together with the conditional operators and logical operators.
The general format for the if...then...else statement is
If conditions Then
VB expressions
Else
VB expressions
End If
Similarly we can use nested else if.
Department of Information Technology/GUI & DBM(Sem: III) Page 25
26. K. J. Somaiya Institute of Engineering & Information Technology
2) Select case statement is multi way flow control statement
The general format is
Select case textexpression
Case exp1 list of vb statements
Case exp2 list of vb statements
End select
We have various looping statements in visual basic. Most commonly use are
1) for ------ next statement
General format is
For i=0 to n
Vb statements
In body of loop
Next i
2) while -----wend statement
General format is
While condition
Vb statements
In body of loop
wend
Along with all these controls we use most common built in function msgbox()
MsgBox() function.
The function displays a dialog box with a message and waits for the user
to close it by clicking on a button.
Conclusion: All forms are designed with required fields and relevant properties of control fields
are set.
Reference book:Visual Basic 6 programming Black Book
Author:Steven Holzner
Publication:Dreamtech
Department of Information Technology/GUI & DBM(Sem: III) Page 26
27. K. J. Somaiya Institute of Engineering & Information Technology
Program :
Go to start menu
Select programs
Select Microsoft visual studio
Select Microsoft visual basic 6.0
Editor will be opened
Which will have tool box on the leftmost side
Properties , project explorer, layout windows on rightmost side
Just drag and drop desire controls from tool box and set properties in properties window(mainly
caption and name properties of every control)
Output :
e.g employee form
Similarly all other forms can be designed
Department of Information Technology/GUI & DBM(Sem: III) Page 27
28. K. J. Somaiya Institute of Engineering & Information Technology
Experiment No:- 10
Aim : To establish the SQL server 2000 and VB 6.0 connectivity through ADO.
Resources Used : VB 6.0, Microsoft Windows Xp professional Ms SQL server 2000.
Theory :
ADO is the object-based interface that provides a logical set of objects that can be accessed
from code.These objects are:
Connection : Establishes the connection with the data base.
Property:
connectionstring Valuse of these property is string specifying loction of the database.
Methods:
Open( ) : used to open connection with database(if path is passed as parameter and if connection
string property is set then all paramerer to open are optional)
Close() : used to close connection opened by open method
Execute() : executes query on database and returns recordset object.
Command. Defines the commands that will be executed against the database.
Recordset. Contains the data that is retrieved from the database.
EOF and BOF are only propertyies of recordset object used to check whthere recordset is empty
or not.
These objects present an interface in the form of properties and methods that can be
queried and manipulated. ADO was specifically developed to be small, lightweight, fast and
feature
complete . for the database applications or for the Internet.
An important thing in ADO is that the objects in this model are not dependant on one
another. This means that one can create instances of objects independent of one another, for
example, one can create a Recordset object without creating a connection object.
Unlike the older technologies, ADO is more flexible, ADO code is easier to write, read and
maintain. ADO is built on top of OLE DB and is capable of accessing any sort of data that is
wrapped
and exposed by an appropriate OLE DB provider.
Department of Information Technology/GUI & DBM(Sem: III) Page 28
29. K. J. Somaiya Institute of Engineering & Information Technology
Conclusion: There are many techniques for connecting database with front end. In this
experiment SQL server 2000 connectivity using V B 6.0 ADO is studied
Reference book:Visual Basic 6 programming Black Book
Author:Steven Holzner
Publication: Dreamtech
Program :
Create system DSN
Go to control panal administrative tools ODBC data sources select system dsn tab click
add Select driver (SQL server) finish write dsn name and server name - click next
click next change default database to your database name- click next finish test data
source tested successfully ok ok ok
Design GUI
Now in VB design form and drag and drop ADODC control on it. If control is not available in the
tool box then press ctrl + T to display component box and click in text box Microsoft Ado data
control 6.0(OLE DB) to add it to tool box.
In the properties window of the ADODC control click connectionstring property and build it.
For every control that is displaying data retrived from relation set datasource and datafield
property correctly.
Output :
Department of Information Technology/GUI & DBM(Sem: III) Page 29