Topics Today include
TopicsToday include
The .Net Framework
The .Net Framework
Studio .Net Environment
Studio .Net Environment
VB .Net
VB .Net
Introduction to VB .Net
Introduction to VB .Net
Loops and Control Structures
Loops and Control Structures
3.
The .Net Framework
The.Net Framework
What is the .Net Framework
What is the .Net Framework
Common Language Runtime
Common Language Runtime
.Net Managed Assemblies
.Net Managed Assemblies
Compilation of .Net Code
Compilation of .Net Code
.Net Framework Class Library
.Net Framework Class Library
.Net Languages
.Net Languages
The future of .Net
The future of .Net
4.
What is the.Net
What is the .Net
Framework
Framework
Primarily a development platform
Primarily a development platform
(mostly effects application
(mostly effects application
development)
development)
Consists of two main parts
Consists of two main parts
– Common Language Runtime
Common Language Runtime
– .Net Framework Class Library
.Net Framework Class Library
5.
CLR (Common Language
CLR(Common Language
Runtime)
Runtime)
Provides a “runtime environment”
Provides a “runtime environment”
for the execution of code written in
for the execution of code written in
ANY .Net Language
ANY .Net Language
“
“Manages”
Manages”
– The overall execution of .Net code
The overall execution of .Net code
– Inheritance, Memory, Debugging, and
Inheritance, Memory, Debugging, and
application development across
application development across
Multiple languages
Multiple languages
6.
CLR (Continued)
CLR (Continued)
Languages that utilizes the .Net framework must follow
Languages that utilizes the .Net framework must follow
the CLS
the CLS
– Common Language Specification
Common Language Specification
– Outlines the rules and standards required or needed by the
Outlines the rules and standards required or needed by the
CLR to execute .Net code.
CLR to execute .Net code.
The CLR will execute Managed Assemblies
The CLR will execute Managed Assemblies
Intermediate Languages managed by the CLR are called
Intermediate Languages managed by the CLR are called
Managed Code
Managed Code
The CLR will manage for the IL
The CLR will manage for the IL
– Garbage collection
Garbage collection
– Object instantiation
Object instantiation
– Memory allocation
Memory allocation
Components written in
Components written in Managed Code
Managed Code by the CLR are
by the CLR are
called .Net Managed assemblies
called .Net Managed assemblies
7.
.Net Managed Assemblies
.NetManaged Assemblies
Basic Unit of deployment of .Net
Basic Unit of deployment of .Net
Applications
Applications
Similar to the Microsoft COM Objects
Similar to the Microsoft COM Objects
Each Managed Assembly contains a
Each Managed Assembly contains a Manifest
Manifest
– Hold definitions of other components required
Hold definitions of other components required
for execution of the application
for execution of the application
– Prevents the problems associated with
Prevents the problems associated with
conflicting DLL’s
conflicting DLL’s
– Revision numbers and components are listed in
Revision numbers and components are listed in
the manifest
the manifest
– Two versions of the same DLL can then co-exist
Two versions of the same DLL can then co-exist
8.
Compilation of .Netcode
Compilation of .Net code
All .Net languages are first compiled into an
All .Net languages are first compiled into an
intermediate language called MSIL or IL (Microsoft
intermediate language called MSIL or IL (Microsoft
Intermediate Language)
Intermediate Language)
The MSIL is then “Just In Time” (JIT) compiled at first
The MSIL is then “Just In Time” (JIT) compiled at first
execution of the code and managed by the CLR
execution of the code and managed by the CLR
All MSIL or IL code can be compiled directly to
All MSIL or IL code can be compiled directly to
native code with the following
native code with the following
– Compiling native code will provide faster startup
Compiling native code will provide faster startup
execution of the code
execution of the code
– Performance during execution of the code will then be
Performance during execution of the code will then be
sacrificed
sacrificed
– During JIT Optimization is placed on the
During JIT Optimization is placed on the Managed Code
Managed Code in
in
order to improve performance at the time of execution
order to improve performance at the time of execution
9.
.Net Framework Class
.NetFramework Class
Library
Library
Provide a library of base classes that
Provide a library of base classes that
developers can use in their own
developers can use in their own
applications written in ANY .Net
applications written in ANY .Net
language
language
Because of the use of these base
Because of the use of these base
classes, Inheritance can then be
classes, Inheritance can then be
extensively used in languages that
extensively used in languages that
use the .Net Framework
use the .Net Framework
10.
.Net Languages
.Net Languages
.Net applications can be written by any or a
.Net applications can be written by any or a
combination of many .Net languages
combination of many .Net languages
Languages include
Languages include
– VB .Net
VB .Net
– C#
C#
– J#
J#
– Managed C++ (default in studio is set for managed C++)
Managed C++ (default in studio is set for managed C++)
Applications can be developed without the use of
Applications can be developed without the use of
Studio .Net
Studio .Net
– Applications can be developed still using a simple text
Applications can be developed still using a simple text
editor
editor
– ASP .Net Applications as well as other apps can be still
ASP .Net Applications as well as other apps can be still
developed using notepad
developed using notepad
11.
The future ofthe .Net
The future of the .Net
Framework
Framework
Standards were release in 2000 from Microsoft to the community
Standards were release in 2000 from Microsoft to the community
GNU .Net is a project in the Linux community that is presently developing
GNU .Net is a project in the Linux community that is presently developing
a CLR to run in the Linux environment
a CLR to run in the Linux environment
Languages planned to include the CLS are
Languages planned to include the CLS are
– APL
APL
– COBOL
COBOL
– Eifel
Eifel
– Fortran
Fortran
– Haskel
Haskel
– Mercury
Mercury
– Mondrian
Mondrian
– Oberon
Oberon
– Pascal
Pascal
– Perl
Perl
– Python
Python
– RPG
RPG
– Scheme
Scheme
12.
Studio .Net Environment
Studio.Net Environment
The IDE
The IDE
Studio .Net
Studio .Net
The Start Page
The Start Page
Problems with Studio .Net in the lab
Problems with Studio .Net in the lab
environment
environment
13.
Studio .Net
Studio .Net
All present .Net languages are included under
All present .Net languages are included under
one development environment
one development environment
– When using any one of the languages, the studio must
When using any one of the languages, the studio must
be used (there is no longer an environment for each
be used (there is no longer an environment for each
language)
language)
– You have to start a new solution/project
You have to start a new solution/project
Projects are containers that contain the files associated
Projects are containers that contain the files associated
with a particular project
with a particular project
A solution is a container that contains one or more
A solution is a container that contains one or more
projects or project containers
projects or project containers
When the IDE is started you have the Projects
When the IDE is started you have the Projects
tab, online resources, and My Profile
tab, online resources, and My Profile
14.
The Start Page
TheStart Page
Previous Projects
Tab for
this view
Tab for
Additional Help
Profile and
environment settings
Start a new
project
Open a project
in a diff. location
15.
Problems with Studio.Net
Problems with Studio .Net
environment in the lab
environment in the lab
.Net security must allow access to the J: drive or
.Net security must allow access to the J: drive or
the local intra net in order to work properly
the local intra net in order to work properly
Problems arise when debugging apps on an
Problems arise when debugging apps on an
ASP .Net server that is not part of the current
ASP .Net server that is not part of the current
domain (CLC) Basic apps will still work fine
domain (CLC) Basic apps will still work fine
These problems are not present if IIS and remote
These problems are not present if IIS and remote
debugging tools are installed on the client
debugging tools are installed on the client
machine
machine
– This solution is fine for students but is not practical for a
This solution is fine for students but is not practical for a
lab
lab
– Due to security holes of IIS you can have hundreds of
Due to security holes of IIS you can have hundreds of
security risks on a given network.
security risks on a given network.
– In the Real world situation, all apps will be placed on a
In the Real world situation, all apps will be placed on a
server anyway
server anyway
16.
Visual Basic .Net
VisualBasic .Net
General Features
General Features
Additional Features of VB .Net
Additional Features of VB .Net
What has changed in VB .Net
What has changed in VB .Net
17.
General features
General features
It is an object oriented language
It is an object oriented language
– Students do better with this subject when they have a firm understanding of
Students do better with this subject when they have a firm understanding of
objects
objects
– In the past VB had objects but focus was not placed on them
In the past VB had objects but focus was not placed on them
– VB .Net use objects and inheritance with everything
VB .Net use objects and inheritance with everything
Uses exception handling extensively
Uses exception handling extensively
– New techniques are shown to the student for providing feedback from their
New techniques are shown to the student for providing feedback from their
programs in order to help trouble shoot errors
programs in order to help trouble shoot errors
– Like with most OOP languages, exceptions that are not handled will cause
Like with most OOP languages, exceptions that are not handled will cause
programs to abnormally end or exit
programs to abnormally end or exit
Uses “generics” with creating classes and Sub programs
Uses “generics” with creating classes and Sub programs
– Can use the top data type on inheritance of type Object
Can use the top data type on inheritance of type Object
– Used for late binding of data types and is quite useful when implementing
Used for late binding of data types and is quite useful when implementing
stacks or queues of any data type (.Net 2.0)
stacks or queues of any data type (.Net 2.0)
Provides a quick way to develop heavy duty applications in a windowing
Provides a quick way to develop heavy duty applications in a windowing
environment
environment
It is a useful tool for developing event driven programs
It is a useful tool for developing event driven programs
18.
Additional Feature of
AdditionalFeature of
VB .Net
VB .Net
Can create both windows applications and web
Can create both windows applications and web
applications at the click of a mouse button
applications at the click of a mouse button
The interface between the Databases and applications
The interface between the Databases and applications
– Are the same between web apps and windows apps
Are the same between web apps and windows apps
– All data are transferred between the apps in XML format
All data are transferred between the apps in XML format
regardless if it is a web application or a windows application
regardless if it is a web application or a windows application
– A copy of the data from the database is loaded into a data
A copy of the data from the database is loaded into a data
set.
set.
– Persistent connections between the application and the
Persistent connections between the application and the
database no longer exists
database no longer exists
Every form is a class and new forms now have to be
Every form is a class and new forms now have to be
instantiated
instantiated
VB .Net is still not case sensitive
VB .Net is still not case sensitive
19.
What is Notin VB .Net
What is Not in VB .Net
Data Controls
Data Controls
– Because of the different way that the apps connect to the
Because of the different way that the apps connect to the
database, there is no longer the support of data controls
database, there is no longer the support of data controls
in VB .Net
in VB .Net
– Persistent connections with the database is no longer
Persistent connections with the database is no longer
present
present
Object instantiation is now done differently
Object instantiation is now done differently
Garbage collection for references that lose there
Garbage collection for references that lose there
objects are done periodically not when the
objects are done periodically not when the
reference lose its scope
reference lose its scope
Periodic changes throughout the language making
Periodic changes throughout the language making
it vastly different from VB 6.0 in order to make it
it vastly different from VB 6.0 in order to make it
compliant to the .Net Framework and the CLS
compliant to the .Net Framework and the CLS
20.
The Introduction to
TheIntroduction to
VB .Net
VB .Net
Data Types in VB .Net
Data Types in VB .Net
Functions and Sub Procedures
Functions and Sub Procedures
Practice Examples
Practice Examples
21.
Data Types inVB .Net
Data Types in VB .Net
Data Types and possible values
Data Types and possible values
– Integer -> -2,147,483,648 (4 bytes)
Integer -> -2,147,483,648 (4 bytes)
– Double -> floating point numbers with 14 digits of accuracy
Double -> floating point numbers with 14 digits of accuracy
(8 Bytes)
(8 Bytes)
– Decimal -> decimal values ( 16 bytes replaced currency in 6.0)
Decimal -> decimal values ( 16 bytes replaced currency in 6.0)
– Date -> the date (8 Bytes)
Date -> the date (8 Bytes)
– Byte -> 0 to 255 (1 Byte)
Byte -> 0 to 255 (1 Byte)
– Char -> Unicode character (2 Bytes)
Char -> Unicode character (2 Bytes)
– Boolean ->True or false value (2 Bytes)
Boolean ->True or false value (2 Bytes)
– Single -> floating point number with 6 digits of accuracy (4 bytes)
Single -> floating point number with 6 digits of accuracy (4 bytes)
– Short -> 2 byte integer
Short -> 2 byte integer
– Long -> 8 byte integer
Long -> 8 byte integer
– String -> an arrangement of alpha-numeric characters varies in
String -> an arrangement of alpha-numeric characters varies in
length
length
– Object -> any data type 4 bytes
Object -> any data type 4 bytes
22.
Functions and Sub
Functionsand Sub
procedures / Programs in
procedures / Programs in
VB .Net (Methods)
VB .Net (Methods)
Functions and sub procedures must either have a sub or
Functions and sub procedures must either have a sub or
function keyword in the function or sub procedure
function keyword in the function or sub procedure
heading
heading
They can be either public or private (following the same
They can be either public or private (following the same
conventions in OOP languages such as C++ or Java)
conventions in OOP languages such as C++ or Java)
All parameters are passed by value by default in VB .Net
All parameters are passed by value by default in VB .Net
Parameters of any data type may be passed by reference
Parameters of any data type may be passed by reference
All Objects and arrays are passed by reference not value
All Objects and arrays are passed by reference not value
All events are handled by a sub procedure in VB .Net
All events are handled by a sub procedure in VB .Net
Functions return a value and Sub Procedures do Not
Functions return a value and Sub Procedures do Not
23.
Practice example
Practice example1
1
You can use the text book given to you to
You can use the text book given to you to
get the basics needed in programming VB
get the basics needed in programming VB
starting on page 477
starting on page 477
Getting familiar with VB .Net
Getting familiar with VB .Net
– Write a program that will take text from one
Write a program that will take text from one
text box and place that text in another text
text box and place that text in another text
box with a click of a button
box with a click of a button
– Take a look at the attributes of each control
Take a look at the attributes of each control
A control can be a button text box etc.
A control can be a button text box etc.
Each control should contain names that follow VB
Each control should contain names that follow VB
specifications i.e. txtBox1 txtBox2 btnMove
specifications i.e. txtBox1 txtBox2 btnMove
Each name as always should be meaningfull
Each name as always should be meaningfull
24.
Practice Example 2
PracticeExample 2
Using Functions in VB .Net
Using Functions in VB .Net
– Use the text boxes from the previous example
Use the text boxes from the previous example
– Add a text box
Add a text box
– Provide a function that adds the values of text
Provide a function that adds the values of text
box 1 and text box 2
box 1 and text box 2
– Place the answer in text box3
Place the answer in text box3
– Use variables of type double and use the
Use variables of type double and use the
CDbl() function to convert the string value of
CDbl() function to convert the string value of
the text box to a double
the text box to a double page 485
page 485 in your text
in your text
25.
Loops and control
Loopsand control
structures
structures
The If Statement
The If Statement
The Select Case Statement
The Select Case Statement
The Do While and Loop While loops
The Do While and Loop While loops
The For Loop
The For Loop
26.
The IF Statement
TheIF Statement
Every If statement must contain a then and an end if
Every If statement must contain a then and an end if
Example:
Example:
– If Num1 < 2 Then
If Num1 < 2 Then
MessageBox.show(“The value is less than 2”)
MessageBox.show(“The value is less than 2”)
End If
End If
– If Num1 <> 4 then
If Num1 <> 4 then
MessageBox.Show(“The value is not 4”)
MessageBox.Show(“The value is not 4”)
End If
End If
The relational operators that can be used in VB are
The relational operators that can be used in VB are
– >
>
– <
<
– =
=
– >=
>=
– <=
<=
– <> (Not equal to)
<> (Not equal to)
27.
The Select Casestatement
The Select Case statement
The select case statement is a lot like the
The select case statement is a lot like the
switch statement in Java
switch statement in Java
It can use ANY data type in VB
It can use ANY data type in VB
Example
Example
Select Case Num1
Select Case Num1
Case 1 DoSomeThing()
Case 1 DoSomeThing()
Case 2 Do SomethingElse()
Case 2 Do SomethingElse()
End Select
End Select
Yes you can use strings as well
Yes you can use strings as well
28.
Do While Loops
DoWhile Loops
Do while loops evaluate the expression
Do while loops evaluate the expression
first then executes the Loop Body
first then executes the Loop Body
Act much in the same as All While
Act much in the same as All While
loops in languages like C++ and Java
loops in languages like C++ and Java
Example
Example
Do While Num1 < 10
Do While Num1 < 10
Num1 += 1
Num1 += 1
Loop
Loop
29.
Loop While Loops
LoopWhile Loops
The Body of the Loop is executed first
The Body of the Loop is executed first
then the expression is evaluated
then the expression is evaluated
The loop will execute at least once
The loop will execute at least once
This is a lot like the do while loop in Java
This is a lot like the do while loop in Java
and students get confused with this
and students get confused with this
subtle change
subtle change
Example
Example
Do
Do
Num1 += 1
Num1 += 1
Loop While Num1 < 10
Loop While Num1 < 10
VB .Net SeminarDay 2
VB .Net Seminar Day 2
June 8, 2004
June 8, 2004
32.
Microsoft SQL Server
MicrosoftSQL Server
MS SQL Basics
MS SQL Basics
The Enterprise Manager
The Enterprise Manager
Creating Databases
Creating Databases
Connecting to Databases
Connecting to Databases
The use of the Data Set
The use of the Data Set
Exception Handling
Exception Handling
33.
Microsoft SQL Basics
MicrosoftSQL Basics
Differences between MS SQL and
Differences between MS SQL and
Access
Access
Advantages of MS SQL
Advantages of MS SQL
Quirky things with SQL
Quirky things with SQL
Connecting to the database with the
Connecting to the database with the
manager
manager
34.
Differences between MS
Differencesbetween MS
SQL and Access
SQL and Access
SQL More Powerful than MS Access
SQL More Powerful than MS Access
– Larger data types are available
Larger data types are available
– Connection over a network provide
Connection over a network provide
access to multiple clients
access to multiple clients
– Blob data type available
Blob data type available
A client is required to connect to the
A client is required to connect to the
SQL Database
SQL Database
35.
Advantages of MSSQL
Advantages of MS SQL
Can handle multiple users at one time
Can handle multiple users at one time
Ideal for web sites and web
Ideal for web sites and web
applications
applications
Contain the BLOB (Binary Large
Contain the BLOB (Binary Large
Object) which enables a user to store
Object) which enables a user to store
images in a database
images in a database
Larger numeric values can be stored in
Larger numeric values can be stored in
each field
each field
36.
Quirky problems withSQL
Quirky problems with SQL
No Auto Number Data Type in MS SQL
No Auto Number Data Type in MS SQL
Auto number is an integer data type
Auto number is an integer data type
Identity is set to yes
Identity is set to yes
And the seed is set to one
And the seed is set to one
This gives you the option to set the
This gives you the option to set the
starting number and the increment
starting number and the increment
you want the auto number to have
you want the auto number to have
37.
Enterprise Manager
Enterprise Manager
Connecting to the database
Connecting to the database
Getting through the confusion of
Getting through the confusion of
locating databases
locating databases
Defining the different containers in
Defining the different containers in
the Manager
the Manager
38.
Connecting to theDBMS
Connecting to the DBMS
Start the Enterprise Manager
Start the Enterprise Manager
Right Click SQL Server group
Right Click SQL Server group
39.
Connecting to theDBMS
Connecting to the DBMS
Click on SQL Server
Click on SQL Server
Registration
Registration
Click next
Click next
In the text box
In the text box
labeled Available
labeled Available
Servers type
Servers type
Sigma.vbnet.matcm
Sigma.vbnet.matcm
p.ncc.edu
p.ncc.edu
Click Add then next
Click Add then next
40.
Connecting to theDBMS
Connecting to the DBMS
Click on SQL Server login
Click on SQL Server login
Username is the first six letters of
Username is the first six letters of
your last name and your first initial
your last name and your first initial
Password is vbnet
Password is vbnet
Click next and click next again
Click next and click next again
Click Finish
Click Finish
Click close on the next dialog box
Click close on the next dialog box
41.
Getting through the
Gettingthrough the
concussion
concussion
MS SQL Enterprise Manager will display
MS SQL Enterprise Manager will display
ALL of the databases located on the
ALL of the databases located on the
server
server
Access to each database is controlled by
Access to each database is controlled by
the DBMS
the DBMS
ALL tables are displayed in each database
ALL tables are displayed in each database
This includes tables that are used by the
This includes tables that are used by the
DBMS
DBMS
42.
The Containers inSQL
The Containers in SQL
Each container
Each container
has a specific
has a specific
role
role
Student
Student
Databases are
Databases are
in the
in the
databases
databases
container
container
43.
Database Container
Database Container
Every students
Every students
database is displayed
database is displayed
Only the database
Only the database
that the student has
that the student has
permissions for can
permissions for can
be opened
be opened
Click on the database
Click on the database
container with your
container with your
username
username
Creating the Database
Creatingthe Database
Creating tables
Creating tables
Properties of the data types
Properties of the data types
Entering and Displaying Data in
Entering and Displaying Data in
database Tables
database Tables
46.
Creating Tables
Creating Tables
Right click on the table container
Right click on the table container
Click new table
Click new table
This is a lot like the Access interface
This is a lot like the Access interface
with different data types.
with different data types.
At this points explore the interface
At this points explore the interface
and notice the differences
and notice the differences
47.
Properties of DataFields
Properties of Data Fields
Each Data Field has a length property
Each Data Field has a length property
This sometimes causes a problem with
This sometimes causes a problem with
students who make this field too small
students who make this field too small
Each data Field can also allow null values
Each data Field can also allow null values
After defining each column and setting all
After defining each column and setting all
the properties set the primary key by
the properties set the primary key by
right clicking on the field that is to be the
right clicking on the field that is to be the
key
key
48.
Entering and Displaying
Enteringand Displaying
Data
Data
Right Click the table
Right Click the table
Click Open Table
Click Open Table
Click Return All Rows
Click Return All Rows
From here you can view and enter
From here you can view and enter
new data into the table
new data into the table
49.
Practice Example 1
PracticeExample 1
Creating a Table in VB .Net
Creating a Table in VB .Net
Create a table of customers in a hardware store
Create a table of customers in a hardware store
Columns will include
Columns will include
– Customer ID
Customer ID
– First Name
First Name
– Last Name
Last Name
– Address
Address
– Zip Code
Zip Code
Fill the table with data
Fill the table with data
Display that data
Display that data
50.
Connecting to thedatabase
Connecting to the database
with VB .Net Applications
with VB .Net Applications
The Data Provider
The Data Provider
The Data Set
The Data Set
The use of the wizard
The use of the wizard
51.
The Data Adapter
TheData Adapter
Needed to connect to every DBMS
Needed to connect to every DBMS
Must Use the Adapter that
Must Use the Adapter that
represents the DBMS you are going
represents the DBMS you are going
to use
to use
We are going to use the
We are going to use the
SQLDataAdapter Object
SQLDataAdapter Object
Holds the information on how to
Holds the information on how to
52.
The Data Provider
TheData Provider
Manipulates data through the use of SQL
Manipulates data through the use of SQL
statements or commands
statements or commands
Hold connection information to the
Hold connection information to the
Database
Database
Contain two Major components
Contain two Major components
– Data Adapter Object – updates data in the
Data Adapter Object – updates data in the
dataset
dataset
– Connection Object – maintains the connection
Connection Object – maintains the connection
53.
The Data Set
TheData Set
Holds data returned from a
Holds data returned from a
procedure or Query performed by
procedure or Query performed by
the data adapter
the data adapter
Provides a local “Copy” of the data
Provides a local “Copy” of the data
from the table on the local machine
from the table on the local machine
Prevents persistent connections
Prevents persistent connections
with the database and reduces
with the database and reduces
network traffic
network traffic
54.
The use ofthe wizard
The use of the wizard
Give Demo on using the wizard
Give Demo on using the wizard
55.
The Data Set
TheData Set
Generating the data set object
Generating the data set object
The use of the onload event handler
The use of the onload event handler
Binding controls
Binding controls
Creating navigation for a database
Creating navigation for a database
56.
Generating the DataSet
Generating the Data Set
Object
Object
Once the Data Adapter and the
Once the Data Adapter and the
connection object is created click on
connection object is created click on
Data in the menu
Data in the menu
Click generate dataset
Click generate dataset
Give a name to the dataset
Give a name to the dataset
Click OK
Click OK
57.
The use ofthe onLoad
The use of the onLoad
event Handler
event Handler
Double click the form
Double click the form
Place the fill method in the Load
Place the fill method in the Load
event handler
event handler
This will fill the dataset object with
This will fill the dataset object with
the data from the table when the
the data from the table when the
form loads
form loads
Example
Example
SQLDataAdapter1.Fill(MyDataSet1)
SQLDataAdapter1.Fill(MyDataSet1)
58.
Binding Controls
Binding Controls
Once you create a data set you can then
Once you create a data set you can then
bind the controls of the form to fields or
bind the controls of the form to fields or
columns of the database table
columns of the database table
This is done with in the Bindings property
This is done with in the Bindings property
in the text box properties sheet
in the text box properties sheet
Under the bindings property click text
Under the bindings property click text
and then the field you wish to bind to the
and then the field you wish to bind to the
text box
text box
59.
Creating navigation fora
Creating navigation for a
database
database
Managed by the BindingManagerBase Object
Managed by the BindingManagerBase Object
This object contains the Position Property the
This object contains the Position Property the
holds the current position of the record in the
holds the current position of the record in the
dataset
dataset
This is done by adding one to the position
This is done by adding one to the position
attribute of the object
attribute of the object
Methods of this object includes
Methods of this object includes
– Addnew()
Addnew()
– EndCurrentEdit()
EndCurrentEdit()
– CancelCurrentEdit() -> provides a role back feature
CancelCurrentEdit() -> provides a role back feature
– RemoveAt() -> deletes current row at given position
RemoveAt() -> deletes current row at given position
60.
Exception Handling
Exception Handling
Implementation
Implementation
Use try catch block much the same in Java
Use try catch block much the same in Java
Can help trouble shoot connections to databases
Can help trouble shoot connections to databases
Very important to use when filling the dataset
Very important to use when filling the dataset
Example
Example
Try
Try
SqlDataAdapter1.Fill(DataSet11)
SqlDataAdapter1.Fill(DataSet11)
Catch
Catch ex
ex As
As Exception
Exception
MessageBox.Show("Error will dataset fill")
MessageBox.Show("Error will dataset fill")
End
End Try
Try
61.
Practice Example 2
PracticeExample 2
Connecting a form to your Hardware customers
Connecting a form to your Hardware customers
Create a form with text fields for each column
Create a form with text fields for each column
– Create the data Adapter and Data Connection with the
Create the data Adapter and Data Connection with the
use of the wizard
use of the wizard
– Create the data set object
Create the data set object
– Create the onload event handler to fill the data set
Create the onload event handler to fill the data set
– Bind your controls
Bind your controls
– Be sure to use exception handling for filling the data
Be sure to use exception handling for filling the data
set
set
– Create a Next button to navigate to the next record in
Create a Next button to navigate to the next record in
the database
the database
VB .Net SeminarDay 3
VB .Net Seminar Day 3
June 9, 2004
June 9, 2004
64.
Topics
Topics
Adding andEditing Records
Adding and Editing Records
Updates and deletes with Bound controls
Updates and deletes with Bound controls
Classes and Modules in VB .Net
Classes and Modules in VB .Net
Menus
Menus
From design
From design
MDI (Multi Document Interfaces)
MDI (Multi Document Interfaces)
Bound and unbound controls in VB .net
Bound and unbound controls in VB .net
Why Unbound controls are used
Why Unbound controls are used
65.
Adding and Editing
Addingand Editing
Records
Records
When Adding records
When Adding records
– The Position of the dataset should be set to
The Position of the dataset should be set to
the end
the end
– The text boxes should be cleared
The text boxes should be cleared
The AddNew() Method accomplishes all
The AddNew() Method accomplishes all
this in one method call
this in one method call
The AddNew() Method is part of the
The AddNew() Method is part of the
BindingManagerBase Object
BindingManagerBase Object
When changes are being made, a cancel
When changes are being made, a cancel
button should be provided to “Roll Back”
button should be provided to “Roll Back”
changes made to the data set
changes made to the data set
66.
Edit
Edit
When Navigatingthe database the Text
When Navigating the database the Text
boxes should be disabled to prevent
boxes should be disabled to prevent
changes
changes
There should be an edit button that
There should be an edit button that
– Disables the navigation button
Disables the navigation button
– Enables the text boxes for editing
Enables the text boxes for editing
– Provide a cancel button that “Roles Back” the
Provide a cancel button that “Roles Back” the
changes that are made by calling the
changes that are made by calling the
CancelCurrentEdit() method of the
CancelCurrentEdit() method of the
BindingManagerBase Object
BindingManagerBase Object
67.
Update and Deleting
Updateand Deleting
Records
Records
This is done by
This is done by
– Ending the current edit by calling EndCurrentEdit() in
Ending the current edit by calling EndCurrentEdit() in
the BindingManagerBase class
the BindingManagerBase class
– Updating the DB with Update() in the data adapter
Updating the DB with Update() in the data adapter
– Cause the dataset to reflect the changes by calling the
Cause the dataset to reflect the changes by calling the
AcceptChanges() method in the data set
AcceptChanges() method in the data set
Deleting the records
Deleting the records
– First Ask the user if they are sure they want to delete
First Ask the user if they are sure they want to delete
– Use the RemoveAt() method of the
Use the RemoveAt() method of the
BindingManagerBase object
BindingManagerBase object
– Update the database with the Update() method
Update the database with the Update() method
– Have the dataset reflect the change by calling the
Have the dataset reflect the change by calling the
AcceptChanges() method of the dataset object
AcceptChanges() method of the dataset object
68.
Practice Example 1
PracticeExample 1
With the Example finished yesterday
With the Example finished yesterday
– Add an Add Button
Add an Add Button
– Add an Edit Button
Add an Edit Button
– Provide a Save and a delete feature
Provide a Save and a delete feature
– Use exception handling for everything
Use exception handling for everything
69.
Classes and Modulesin VB
Classes and Modules in VB
.Net
.Net
Creating classes in VB .Net
Creating classes in VB .Net
The constructor and Sub procedures
The constructor and Sub procedures
in VB .Net
in VB .Net
The use of Modules
The use of Modules
70.
Creating Classes in
CreatingClasses in
VB .Net
VB .Net
Classes can be added to a project by
Classes can be added to a project by
– Right clicking the project container
Right clicking the project container
– Click add
Click add
– Click add class
Click add class
As in Most OOP Languages VB classes have
As in Most OOP Languages VB classes have
– Public and private attributes
Public and private attributes
– Public and private Methods (called functions or
Public and private Methods (called functions or
sub procedures)
sub procedures)
– Constructors and Destructors (destructors are
Constructors and Destructors (destructors are
not really needed in VB because of garbage
not really needed in VB because of garbage
collection)
collection)
71.
Modules
Modules
Modules canalso be added to a
Modules can also be added to a
project to provide a place for
project to provide a place for
“Global” Methods and Identifiers
“Global” Methods and Identifiers
These Identifiers and methods can
These Identifiers and methods can
be either public or private
be either public or private
Public Identifiers and methods can
Public Identifiers and methods can
be accessed from all of the forms
be accessed from all of the forms
and classes in the VB project
and classes in the VB project
72.
Practice Example
Practice Example
For this Example
For this Example
– Create an Auto Class
Create an Auto Class
– An Auto will have
An Auto will have
Three Attributes
Three Attributes
Three Methods
Three Methods
Two constructors
Two constructors
– Try instantiating the method in the
Try instantiating the method in the
form
form
73.
Menus
Menus
When addingmenus to a form you
When adding menus to a form you
can type in the choice right into the
can type in the choice right into the
menu object
menu object
Click event handlers can then be
Click event handlers can then be
added for each menu choice in the
added for each menu choice in the
same manner as the button
same manner as the button
74.
Form Design
Form Design
Colors are important
Colors are important
– They should be contrast in color
They should be contrast in color
– Ease to read
Ease to read
– Easy on the eyes for long periods of viewing
Easy on the eyes for long periods of viewing
Should provide easy navigation
Should provide easy navigation
Should provide a way to enter the data
Should provide a way to enter the data
easily with just using the keyboard
easily with just using the keyboard
75.
Multi Document
Multi Document
Interfaces(MDI)
Interfaces (MDI)
When creating a form in VB .Net you are creating
When creating a form in VB .Net you are creating
a class
a class
Every class in vb must be instantiated before it is
Every class in vb must be instantiated before it is
used
used
This is accomplished by using the new keyword
This is accomplished by using the new keyword
When the instance of the form is created, the
When the instance of the form is created, the
form can then be visible by calling the forms
form can then be visible by calling the forms
show method
show method
Closing a form does not exit the program. To
Closing a form does not exit the program. To
exit the program the End method should be
exit the program the End method should be
called
called
76.
Practice Example 3
PracticeExample 3
Create a Form that will be a switch
Create a Form that will be a switch
board
board
– Add a form to yesterdays example
Add a form to yesterdays example
– Place a button that will open the
Place a button that will open the
customer form
customer form
– Place a button that will exit the
Place a button that will exit the
program
program
77.
Bound and Unbound
Boundand Unbound
Controls
Controls
So far we have seen the benefits of bound
So far we have seen the benefits of bound
controls
controls
These are ok if you intend to use the same SQL
These are ok if you intend to use the same SQL
query for the whole application
query for the whole application
Once controls are bound to a data set, changes
Once controls are bound to a data set, changes
to the query in the data adapter can not be
to the query in the data adapter can not be
accomplished
accomplished
Unbounded controls give you the power to
Unbounded controls give you the power to
create new data adapters with new queries.
create new data adapters with new queries.
Values can then be placed into the query to find
Values can then be placed into the query to find
specific records in a database
specific records in a database
VB .Net SeminarDay 4
VB .Net Seminar Day 4
June 10, 2004
June 10, 2004
80.
Topics
Topics
ASP .Netbasic applications
ASP .Net basic applications
ASP .Net Database applications
ASP .Net Database applications
Web Forms
Web Forms
Crystal Reports
Crystal Reports
Creating Help Files
Creating Help Files
Demo with Serial port programming and
Demo with Serial port programming and
VB .Net
VB .Net
Handout Certificates
Handout Certificates