Dot Net
Dot Net
• Software platform
• Language neutral
• In other words:
.NET is not a language (Runtime and a library for
writing and executing written programs in any
compliant language)
WHAT IS .NET
• .Net is a new framework for developing
web-based and windows-based applications
within the Microsoft environment.
• The framework offers a fundamental shift
in Microsoft strategy: it moves application
development from client-centric to server-
centric.
.NET – WHAT IS IT?
.NET Application
.NET Framework
Visual Studio.NET
ASP.NET: Web Services Windows
and Web Forms Forms
• Development
Common Language Specification (CLS)
– Mixed language applications
Common• Type System (CTS)
•
Standard class framework Automatic
•
memory• management
– Consistent error handling and safer execution
– Potentially multi-platform
• Deployment
– Removal of registration dependency
– Safety – fewer versioning problems
COMMON LANGUAGE RUNTIME
Multiple Language Support
• CTS is a rich type system built into the CLR
– Implements various types (int, double, etc)
– And operations on those types
• CLS is a set of specifications that language
and library designers need to follow
– This will ensure interoperability between
languages
COMPILATION IN .NET
Code in another
Code in VB.NET Code in C#
.NET Language
Appropriate
VB.NET compiler C# compiler
Compiler
IL(Intermediate
Language) code
CLR just-in-time
execution
INTERMEDIATE LANGUAGE (IL)
• .NET languages are not compiled to machine code. They
are compiled to an Intermediate Language (IL).
• Languages provided by MS
– VB, C++, C#, J#, JScript
• Third-parties are building
– APL, COBOL, Pascal, Eiffel, Haskell, ML,
Oberon, Perl, Python, Scheme, Smalltalk…
ASP.NET
CLR
CLR
.NET TOOL
SUMMARY
Introduction to VB.net
Operators in VB.NET
Arithmetic operators are used to perform arithmetic
Sequence
Functions and Procedures
Selection
If...Then...Else statement
Select Case statement
Iterative
For...Next Loop statement
Do...Loop statement
There are mainly 3 types
of loop:
For Loop
While Loop
Do Loop
Example
WINDOWS
. FORMS
• Open your Visual Studio and select File->New Project and select
Visual Basic from the New project dialog box and select Windows
Forms Application.
• The following picture shows how to crate a new Form in Visual Studio.
Select project type from New project dialog
Box
When you add a Windows Form to your project, many of the forms properties
are set by default. Although these values are convenient, they will not always
suit your programming needs. The following picture shows how is the default
Form look like.
UNIT 3:
Object Oriented Programming in
vb.net
CLASS AND OBJECT
Result: 0
Creating User-Defined Exceptions
You can also define your own exception. User-
defined exception classes are derived from the
ApplicationException class. The following
example demonstrates this −
Live Demo
Module exceptionProg
Public Class TempIsZeroException : Inherits ApplicationException
Public Sub New(ByVal message As String)
MyBase.New(message)
End Sub
End Class
Public Class Temperature
Dim temperature As Integer = 0
Sub showTemp()
If (temperature = 0) Then
Throw (New TempIsZeroException("Zero Temperature found"))
Else
Console.WriteLine("Temperature: {0}", temperature)
End If
End Sub
End Class
Sub Main()
Dim temp As Temperature = New Temperature()
Try
temp.showTemp()
Catch e As TempIsZeroException
Console.WriteLine("TempIsZeroException: {0}", e.Message)
End Try
Console.ReadKey()
End Sub
End Module
When the above code is compiled and
executed, it produces the following result −
You can use a throw statement in the catch block to throw the present object as −
Throw [ expression ]
The following program demonstrates this −
Module exceptionProg
Sub Main()
Try
Throw New ApplicationException("A custom exception _ is being thrown here...")
Catch e As Exception
Console.WriteLine(e.Message)
Finally
Console.WriteLine("Now inside the Finally Block")
End Try
Console.ReadKey()
End Sub
End Module
UNIT :5
Architecture Of ADO.Net
ADO.NET provides a bridge between the front
end controls and the back end database. The
ADO.NET objects encapsulate all the data
access operations and the controls interact
with these objects to display data, thus hiding
the details of movement of data.
THE DATASET CLASS
EnforceConstraints Indicates whether constraint rules are followed when attempting any
update operation.
Events Gets the list of event handlers that are attached to this component.
ExtendedProperties Gets the collection of customized user information associated with the
DataSet.
HasErrors Indicates if there are any errors.
IsInitialized Indicates whether the DataSet is initialized.
Locale Gets or sets the locale information used to compare strings within the
table.
Namespace Gets or sets the namespace of the DataSet.
Prefix Gets or sets an XML prefix that aliases the namespace of the DataSet.
The DataTable class represents the tables in the database. It has the following important properties; most of these
properties are read only properties except the PrimaryKey property:
The following table shows some important methods of the DataTable class:
Properties Description
ChildRelation Returns the collection of child
s relationship.
Columns Returns the Columns collection.
Constraints Returns the Constraints collection.
DataSet Returns the parent DataSet.
DefaultView Returns a view of the table.
ParentRelatio Returns the ParentRelations collection.
ns
PrimaryKey Gets or sets an array of columns as the
primary key for the table.
Rows Returns the Rows collection.
Methods Description
AcceptChanges Commits all changes since the last
AcceptChanges.
Clear Clears all data from the table.
GetChanges Returns a copy of the DataTable with
all changes made since the
AcceptChanges method was called.
GetErrors Returns an array of rows with errors.
ImportRows Copies a new row into the table.
LoadDataRow Finds and updates a specific row, or
creates a new one, if not found any.
Merge Merges the table with another
DataTable.
NewRow Creates a new DataRow.
RejectChanges Rolls back all changes made since the
last call to AcceptChanges.
Reset Resets the table to its original state.
Select Returns an array of DataRow objects.
THE DATAROW CLASS
You also need to add the line of code below to the general declaration section of form module:
Imports System.Data.SqlClient
Imports System.Data.SqlClient
Public Class Form1
End Sub
End Class
+Run your project and see the result.
Now the designing part is over and the next
step is to call the created Crystal Reports in
VB.NET through Crystal Reports Viewer control .
Imports CrystalDecisions.CrystalReports.Engine