Coding & Implementation
Coding & Implementation
Imports System.Data.OleDb
Public Class Form1
Dim con As OleDbConnection
Dim cmd As OleDbCommand
Dim dr As OleDbDataReader
Dim s, s1 As String
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
con = New OleDbConnection
con.ConnectionString = "provider=MSDAORA.1;user
id=scott;password=tiger;datasource=oracle9i"
con.Open()
cmd = New OleDbCommand
cmd.Connection = con
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
s = " select * from crime where name='" & TextBox1.Text & "'"
cmd.CommandText = s
dr = cmd.ExecuteReader
If dr.Read = True Then
s1 = dr.GetValue(1)
If s1 = TextBox2.Text Then
Dim oc As New Form5
oc.Show()
A.I.E.T, Gunthapally 27
System Coding & Implementation
End If
End If
Me.Close()
End Sub
Imports System.Data.OleDb
Public Class Form3
Dim con As OleDbConnection
Dim cmd As OleDbCommand
Dim s As String
Dim uname, password, addr, email As String
Dim cno, k As Integer
Private Sub Form3_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
con = New OleDbConnection
con.ConnectionString = "provider=MSDAORA.1;user
id=scott;password=tiger;datasource=oracle9i"
con.Open()
cmd = New OleDbCommand
cmd.Connection = con
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
uname = TextBox1.Text
password = TextBox2.Text
cno = TextBox3.Text
addr = TextBox4.Text
email = TextBox5.Text
s = "insert into crime values('" & uname & "','" & password & "'," & cno & ",'" & addr &
"','" & email & "')"
A.I.E.T, Gunthapally 28
System Coding & Implementation
cmd.CommandText = s
k = cmd.ExecuteNonQuery()
If k = 1 Then
Dim oa As New Form6
oa.Show()
End If
Me.Close()
End Sub
End Class
A.I.E.T, Gunthapally 29
System Coding & Implementation
Microsoft.NET Framework
The .NET Framework has two main components: the common language runtime and
the .NET Framework class library. The common language runtime is the foundation of
the .NET Framework. You can think of the runtime as an agent that manages code at
execution time, providing core services such as memory management, thread management,
and remoting, while also enforcing strict type safety and other forms of code accuracy that
ensure security and robustness. In fact, the concept of code management is a fundamental
principle of the runtime. Code that targets the runtime is known as managed code, while code
that does not target the runtime is known as unmanaged code. The class library, the other
main component of the .NET Framework, is a comprehensive, object-oriented collection of
reusable types that you can use to develop applications ranging from traditional command-
line or graphical user interface (GUI) applications to applications based on the latest
innovations provided by ASP.NET, such as Web Forms and XML Web services.
A.I.E.T, Gunthapally 30
System Coding & Implementation
The .NET Framework can be hosted by unmanaged components that load the
common language runtime into their processes and initiate the execution of managed code,
thereby creating a software environment that can exploit both managed and unmanaged
features. The .NET Framework not only provides several runtime hosts, but also supports the
development of third-party runtime hosts.
The following illustration shows the relationship of the common language runtime
and the class library to your applications and to the overall system. The illustration also
shows how managed code operates within a larger architecture.
The common language runtime manages memory, thread execution, code execution,
code safety verification, compilation, and other system services. These features are intrinsic
to the managed code that runs on the common language runtime.
With regards to security, managed components are awarded varying degrees of trust,
depending on a number of factors that include their origin (such as the Internet, enterprise
network, or local computer). This means that a managed component might or might not be
able to perform file-access operations, registry-access operations, or other sensitive functions,
even if it is being used in the same active application.
The runtime enforces code access security. For example, users can trust that an
executable embedded in a Web page can play an animation on screen or sing a song, but
A.I.E.T, Gunthapally 31
System Coding & Implementation
cannot access their personal data, file system, or network. The security features of the
runtime thus enable legitimate Internet-deployed software to be exceptionally feature rich.
The runtime also enforces code robustness by implementing a strict type- and code-
verification infrastructure called the common type system (CTS). The CTS ensures that all
managed code is self-describing. The various Microsoft and third-party language compilers
generate managed code that conforms to the CTS. This means that managed code can
consume other managed types and instances, while strictly enforcing type fidelity and type
safety.
The runtime also accelerates developer productivity. For example, programmers can
write applications in their development language of choice, yet take full advantage of the
runtime, the class library, and components written in other languages by other developers.
Any compiler vendor who chooses to target the runtime can do so. Language compilers that
target the .NET Framework make the features of the .NET Framework available to existing
code written in that language, greatly easing the migration process for existing applications.
While the runtime is designed for the software of the future, it also supports software
of today and yesterday. Interoperability between managed and unmanaged code enables
developers to continue to use necessary COM components and DLLs.
A.I.E.T, Gunthapally 32
System Coding & Implementation
The .NET Framework class library is a collection of reusable types that tightly integrate
with the common language runtime. The class library is object oriented, providing types from
which your own managed code can derive functionality. This not only makes the .NET
Framework types easy to use, but also reduces the time associated with learning new features
of the .NET Framework. In addition, third-party components can integrate seamlessly with
classes in the .NET Framework.
For example, the .NET Framework collection classes implement a set of interfaces that
you can use to develop your own collection classes. Your collection classes will blend
seamlessly with the classes in the .NET Framework.
As you would expect from an object-oriented class library, the .NET Framework types
enable you to accomplish a range of common programming tasks, including tasks such as
string management, data collection, database connectivity, and file access. In addition to
these common tasks, the class library includes types that support a variety of specialized
development scenarios. For example, you can use the .NET Framework to develop the
following types of applications and services:
Console applications.
Scripted or hosted applications.
Windows GUI applications (Windows Forms).
ASP.NET applications.
XML Web services.
Windows services.
For example, the Windows Forms classes are a comprehensive set of reusable types that
vastly simplify Windows GUI development. If you write an ASP.NET Web Form
application, you can use the Web Forms classes.
A.I.E.T, Gunthapally 33
System Coding & Implementation
Another kind of client application is the traditional ActiveX control (now replaced by
the managed Windows Forms control) deployed over the Internet as a Web page. This
application is much like other client applications: it is executed natively, has access to local
resources, and includes graphical elements.
In the past, developers created such applications using C/C++ in conjunction with the
Microsoft Foundation Classes (MFC) or with a rapid application development (RAD)
environment such as Microsoft® Visual Basic®. The .NET Framework incorporates aspects
of these existing products into a single, consistent development environment that drastically
simplifies the development of client applications.
The Windows Forms classes contained in the .NET Framework are designed to be
used for GUI development. You can easily create command windows, buttons, menus,
toolbars, and other screen elements with the flexibility necessary to accommodate shifting
business needs.
For example, the .NET Framework provides simple properties to adjust visual
attributes associated with forms. In some cases the underlying operating system does not
support changing these attributes directly, and in these cases the .NET Framework
automatically recreates the forms. This is one of many ways in which the .NET Framework
integrates the developer interface, making coding simpler and more consistent.
A.I.E.T, Gunthapally 34
System Coding & Implementation
able to access or compromise other resources. Because of code access security, many
applications that once needed to be installed on a user's system can now be safely deployed
through the Web. Your applications can implement the features of a local application while
being deployed like a Web page.
The following illustration shows a basic network schema with managed code running
in different server environments. Servers such as IIS and SQL Server can perform standard
operations while your application logic executes through the managed code.
ADO.NET Overview
ADO.NET is an evolution of the ADO data access model that directly addresses user
requirements for developing scalable applications. It was designed specifically for the web
with scalability, statelessness, and XML in mind.
ADO.NET uses some ADO objects, such as the Connection and Command objects,
and also introduces new objects. Key new ADO.NET objects include the DataSet,
DataReader, and DataAdapter.
The important distinction between this evolved stage of ADO.NET and previous data
architectures is that there exists an object -- the DataSet -- that is separate and distinct from
A.I.E.T, Gunthapally 35
System Coding & Implementation
any data stores. Because of that, the DataSet functions as a standalone entity. You can think
of the DataSet as an always disconnected recordset that knows nothing about the source or
destination of the data it contains. Inside a DataSet, much like in a database, there are tables,
columns, relationships, constraints, views, and so forth.
A DataAdapter is the object that connects to the database to fill the DataSet. Then, it
connects back to the database to update the data there, based on operations performed while
the DataSet held the data. In the past, data processing has been primarily connection-based.
Now, in an effort to make multi-tiered apps more efficient, data processing is turning to a
message-based approach that revolves around chunks of information. At the center of this
approach is the DataAdapter, which provides a bridge to retrieve and save data between a
DataSet and its source data store. It accomplishes this by means of requests to the appropriate
SQL commands made against the data store.
The XML-based DataSet object provides a consistent programming model that works
with all models of data storage: flat, relational, and hierarchical. It does this by having no
'knowledge' of the source of its data, and by representing the data that it holds as collections
and data types. No matter what the source of the data within the DataSet is, it is manipulated
through the same set of standard APIs exposed through the DataSet and its subordinate
objects.
While the DataSet has no knowledge of the source of its data, the managed provider
has detailed and specific information. The role of the managed provider is to connect, fill, and
persist the DataSet to and from data stores. The OLE DB and SQL Server .NET Data
Providers (System.Data.OleDb and System.Data.SqlClient) that are part of the .Net
Framework provide four basic objects: the Command, Connection, DataReader and
DataAdapter. In the remaining sections of this document, we'll walk through each part of the
DataSet and the OLE DB/SQL Server .NET Data Providers explaining what they are, and
how to program against them.
The following sections will introduce you to some objects that have evolved, and some
that are new. These objects are:
A.I.E.T, Gunthapally 36
System Coding & Implementation
When dealing with connections to a database, there are two different options: SQL
Server .NET Data Provider (System.Data.SqlClient) and OLE DB .NET Data Provider
(System.Data.OleDb). In these samples we will use the SQL Server .NET Data Provider.
These are written to talk directly to Microsoft SQL Server. The OLE DB .NET Data Provider
is used to talk to any OLE DB provider (as it uses OLE DB underneath).
Connections
Connections are used to 'talk to' databases, and are represented by provider-specific
classes such as SQLConnection. Commands travel over connections and result sets are
returned in the form of streams which can be read by a DataReader object, or pushed into a
Dataset object.
Commands
DataReaders
A.I.E.T, Gunthapally 37
System Coding & Implementation
DataSets
The DataSet object is similar to the ADO Recordset object, but more powerful, and
with one other important distinction: the DataSet is always disconnected. The DataSet object
represents a cache of data, with database-like structures such as tables, columns,
relationships, and constraints. However, though a DataSet can and does behave much like a
database, it is important to remember that DataSet objects do not interact directly with
databases, or other source data. This allows the developer to work with a programming model
that is always consistent, regardless of where the source data resides. Data coming from a
database, an XML file, from code, or user input can all be placed into DataSet objects. Then,
as changes are made to the DataSet they can be tracked and verified before updating the
source data. The Get Changes method of the DataSet object actually creates a second DatSet
that contains only the changes to the data. This DataSet is then used by a DataAdapter (or
other objects) to update the original data source.
The DataSet has many XML characteristics, including the ability to produce and
consume XML data and XML schemas. XML schemas can be used to describe schemas
interchanged via WebServices. In fact, a DataSet with a schema can actually be compiled for
type safety and statement completion.
DataAdapters (OLEDB/SQL)
The DataAdapter object works as a bridge between the DataSet and the source data.
Using the provider-specific SqlDataAdapter (along with its associated SqlCommand and
SqlConnection) can increase overall performance when working with a Microsoft SQL
Server databases. For other OLE DB-supported databases, you would use the
OleDbDataAdapter object and its associated OleDbCommand and OleDbConnection objects.
The DataAdapter object uses commands to update the data source after changes have
been made to the DataSet. Using the Fill method of the DataAdapter calls the SELECT
command; using the Update method calls the INSERT, UPDATE or DELETE command for
each changed row. You can explicitly set these commands in order to control the statements
used at runtime to resolve changes, including the use of stored procedures. For ad-hoc
scenarios, a CommandBuilder object can generate these at run-time based upon a select
statement. However, this run-time generation requires an extra round-trip to the server in
A.I.E.T, Gunthapally 38
System Coding & Implementation
order to gather required metadata, so explicitly providing the INSERT, UPDATE, and
DELETE commands at design time will result in better run-time performance.
About Oracle 9i
Database
A Database is an organized collection of related information. The database
stores data that is useful to us and this data is only a part of the entire data available in and
around us. The organized information of database serves as a base from which desired
information can be retrieved, many meaningful conclusions can be drawn or further
processing the data can make decisions.
The word DATABASE implies that any of the data may be used as key
information to specify queries. In general it often means any accessible collection of
information and in that case only a limited set of the data values may be used to specify
queries.
Hence, the objects ,their attributes and the relationship between them that are of
interest to us are stored in the database that is designed, built and polluted with data for
specific purpose.
A.I.E.T, Gunthapally 39
System Coding & Implementation
DBMS is a collection of interrelated files and a set of programs that allows users
to access and modify these files. A major purpose of DBMS is to provide users with an
abstract view of the data where the system hides certain details of how the data are stored and
maintained. The primary goal of DBMS is to provide an environment that is both convenient
and efficient using retrieving and storing database information. DBMS is integrated software
that has facilities for defining the logical and physical structure of data in a database and for
accessing, entering and deleting data.
Components of DBMS
A.I.E.T, Gunthapally 40
System Coding & Implementation
Schema
A schema is the overall design of the database. It is an outline or a plan that describes
the records and relationships existing in the view. A schema describes the way in which
entities at one level of abstraction can be mapped to the next level.
DBMS have several schemas partitioned according to the levels of abstraction. At the
lowest level is the physical schema , at the intermediate level is the logical schema. In
general, DBMS support one physical schema, one logical schema and several sub schemas.
Architecture of a DBMS
The DBMS architecture, which is also called as ANSCI/SPARC model can be divided
into three levels.
1. Internal level
2. Conceptual level
3. External level
Internal or physical level
Internal level or physical level is at the lowest level of a database abstraction and closest
to the physical storage method used internal level is defined by means of the internal schema.
Conceptual level or logical level
Conceptual level or logical level is at the intermediate level of a database abstraction
and describes what data are stored in the database and what relationships exist among those
data. Conceptual level is defined by means of the conceptual schema.
External level or View level
External level or view level is at the highest level of database. Abstraction where
only portions of the database of concerns to a user of application program are included
External level is defined by means of the external schema.
DMBS architecture indicates how the functions data management in terms of data
insertion, retrieval, updating as well as security, integrity, consistency, scalability etc are
accomplished.
Data Model
A data model is a mechanism that provides the abstraction for database applications. A
data model is the structure of a database, which contains a collection of conceptual tools for
describing data, data relationships, and data semantics and data constraints.
A.I.E.T, Gunthapally 41
System Coding & Implementation
A.I.E.T, Gunthapally 42
System Coding & Implementation
Advantages of DBMS
Redundancy can be avoided to some extent.
Inconsistency can be reduced.
Data can be shared.
Standards can be enforced.
Security restrictions can be applied.
Integrity can be maintained.
Conflicting requirements can be balanced.
Data independence.
Providing backup and recovery.
Providing multiple user interfaces.
Persistent storage for program objects and data structures.
Normalization
Normalization is the process of analyzing the data to be represented and breaking it
down into separate tables in accordance with the principles of relational structure.
Need for Normalization
Normalization reduces redundancy, which is an unnecessary repetition of data and
cause problems with storage and retrieval of data. Redundancy can lead to inconsistencies as
errors are more likely to occur when facts are repeated update anomalies inserting, deleting,
modifying data may cause inconsistencies as there is high likelihood of updating or deleting
data in one relation while omitting to make corresponding changes in other relations. We
identify dependence, which can cause problems when deleting or updating during the process
of normalization.
Normalization helps to simply the structure of tables. A fully Normalized records
consists of a primary key that identifies that entity and a set of attributes that describes the
entity.
Normal Forms
Normalization results in the formation of tables that satisfy certain specified
constraints and represent certain normal forms. Normal forms are table structures with
minimum redundancy. Normal forms are of six types and are as follows:
A.I.E.T, Gunthapally 43
System Coding & Implementation
A.I.E.T, Gunthapally 44