Académique Documents
Professionnel Documents
Culture Documents
com
Kok Choon
6/11/2008
Rapid Application Development with Visual Studio™
Important Information:
You may distribute this book to anyone without modifying the content, all links
and information must be remain in its’ original. Thank you for your attention!
7B
This course is for informational purposes only and the author does not accept any responsibilities for any
liabilities resulting from the use of this information.
While every attempt has been made to verify the information provided here, the author and his referrals
cannot assume any responsibility for errors, inaccuracies or omissions. Any slights of people or
organizations are unintentional.
Contents
A Word from the Author… ......................................................................................................................... 4
Before Start… ............................................................................................................................................ 6
Create the Project and Data Sources ........................................................................................................ 6
Draw controls to forms instead of coding................................................................................................. 13
Unleash the Power of Dataset Designer .................................................................................................. 16
Hierarchical Update with Visual Studio 2008 ........................................................................................... 23
Useful Resources .................................................................................................................................... 30
Many developers still using conventional coding method introduced in VB 6, while these methods are
effective in the old days, but the new and powerful Visual Studio 2005 and 2008 provides even more
efficient programming tools – The RAD Dataset designer and components.
Conventional programmer will code their way to the end of the project, but new Visual Studio 2005 and
2008 allows developer to “drag and draw” their application from start till the end! They call it Rapid
Application Development. Programmer from Borland Delphi in the old days already familiar with RAD
programming, but until Microsoft replaced them with the powerful Dataset Designer, Form Designer and
other visual tools, most of them switch to Visual Studio, and I am one of the Delphi developers.
From my experience with Visual Studio 2005, you can write code 500% faster than another conventional
programmer with the help of visual inheritance, form designer and dataset designer. Some developer still
relied on code generation tools such as CodeSmith to generate Insert, Update and Delete stored
procedure for SQL server, and certainly data access code in Visual Studio!
The biggest problem for RAD programming not common between Visual Studio 2005 developers is lack of
documentation and tutorial… and VS2008 has improved this weakness. Now you can find lots of video
tutorial and web demos showing you how to code your software in RAD style; I predict the RAD
programming will be become very popular in the next 3 years.
RAD will work very well because its’ utility has become to mature through the time, and developer can
lower the development cost and deliver the project faster. If you don’t believe me, try it yourself, compare
the “coding style” and “drawing style”, definitely you will agree with me that: Let the tools code for you
always the fastest way.
For your information: Visual Studio 2008 added many cool features, you can now do 3-tier programming
easier than before! and the Microsoft Synchronization framework for ADO.Net brings RAD into offline
application; You can use the software offline and upload any pending updates that you make during offline
into the server by batch, very cool feature! And the best part, you can do that RAD all the way…
hope this book can bring the new age programming into your existing skills, we can expect to see more
tools coming from Microsoft in the near future.
While all efforts are done to make this book perfect, inevitably there might be technical mistakes or editing
errors, please feel free to contact the author at kkchoon@cynics-soft.com for comment and questions, I
will try to revise the book and answer your question as soon as possible.
Warmest Regards,
CYNICS SOFTWARE
www.cynics-soft.com
B
Before Sta
art…
You need to download
d the Northwindd sample dattabase from Microsoft website
w or go
o to the end of
o this
bo
ook, and follow the resources links to
t create the
e sample Noorthwind DB before proceeed.
C
Create the
e Project and Data
a Sources
s
Crea
ate new projject, select Windows
W
and then Windoows Forms Application,
A
save
e the projectt as RADDemo.
Fiigure 1
You
u should be able
a to see the
t
Form
m1.vb.
Fiigure 2
Now
w, go to the menu,
m selecct “Data” ->
“Sho
ow Data Sou urces” or use e the
shortcut key “Sh
hift+Alt+D”.
Fiigure 3
You
ur should see e the “Data Sources”
S
panel, click on “Ad
“ New Datta
Sou
urce…”.
Fiigure 4
Figure5
Figure 6
Figure 7
Figure 8
Fiigure 9
Fiigure 10
w, select Ord
Now ders, EmployyeeID.
** Also
A change CustomerID
D to
“Combobox”.
Fiigure 11
D
Draw conttrols to fo
orms inste
ead of co
oding
In
n this section
n, you will lea
arn how to drag
d and dro
op the contro
ols from Data
a Sources in
nto the Winddows Form
Designer. Vissual Studio has
h powerful tools in the Data Sourcces Panel, yoou can assig
gn all controlls to the
Fiields.
Afte
er that, selecct Orders andd change
the DataGridVie ew to Detailss.
Fiigure 12
Now
w drag and drop
d Orders from
aSources into the form.
Data
Fiigure 13
Afte
er Drag the Orders
O table, you
should assign Customer
C ID and
Empployee ID coontrols to rettrieve data
from
m which table
e.
Drag
g Employee table from the
t Data
Sou
urces into Em
mployee ID combobox.
c
Fiigure 14
Go to
t source vie ew, you should be
e to see the loading code
able e
auto
omatic generated.
Fiigure 15
Fiigure 16
U
Unleash th
he Powerr of Datas
set Design
ner
Dataset Desig gner is the most
m powerfuul tools availlable in Visu
ual Studio 20
005 and 2008; many devvelopers
diidn’t even kn
now their exiistence or im
mportance.
Th
he only reasson develope
er do not use
e them are, they do not know how to
o customize
e it !
Fiigure 17
All codes
c generrated by the tools, you
can then configuure the toolss’
generated sourcce.
Fiigure 18
Afte
er Click on th
he
“Ord
dersTableAd dapter” in pre
evious
step
p, now look ata your Prop perties
Pannel, you will notice
n all 4 commands
c
generated for yo ou.
Fiigure 19
The
e standard coommand sett might not
get what you waant; I will shoow you
how e it with filter.
w to configure
Now
w select OrdersTableAda apter
again, right clickk and select “Add
Que
ery”.
Fiigure 20
Fiigure 21
Figure 22
Figure 23
Figure 24
Figure 25
The
e FillBy and Get
G DataBy Method is
generated.
Fiigure 26
Fiigure 27
Fiigure 28
Double click on
o the button
n and switch
h to code vie
ew automaticcally. Add the fillby meth
hod in the click event:
M
Me.OrdersTa bleAdapter.F
Fillby(Me.No
orthwindData
aset.Orders, STARTID, ENDID)
Please note that the STA ARTID can be e replace byy “0000” or anything.
a If you
y add two more editbo
ox, you can
acctually pass in the editbo
ox.text into the
t method directly.
d
Unfortunate this tutorial only applies to VS2008, VS2005 still requires a bit coding!
Figure 29
Now
w you need to t drag the Order
O
Deta
ails into the form.
Fiigure 30
If yo
ou select thee Order Deta
ails instead
of Orders,
O then Order Details, the
data w not be filter by the
a in the grid will
Orde erID…
Fiigure 31
Fiigure 32
Fiigure 33
Figure 34
Figure 35
Figure 36
Click OK Button.
Figure 37
Fiigure 38
Now hit F5 co
ompile and run, if everything setup correct,
c you will
w see the Order Detaills grid follow
w Order
ta
able when na
avigating.
Thhe ProductID
D in the Grid
d should sho ow Product Name
N (DisplayName), and every tim
me you chang
ge the
prroduct name
e, the producctID will be updated
u acco
ordingly.
Fiigure 39
You should nootice below the form dessigner, is all the compon
nents repressentation icon, one of the
e new
co
omponent iss TableAdaptterManager,, this compo onent allows you to updaate multiple table
t at once
e!
Fiigure 40
Fiigure 41
Th
his statemennt: “Me.TableAdapterMa anager.Upda ateAll(Me.No orthwindData
aset)” will do
o all the upda
ate for
bo
oth tables, even
e you hav
ve 3 or 4 or many tabless, it will mana
age the update accordin ngly.
Because deleete and inserrt sequence are not the same, witho
out TableAda
apterManage
er, develope
er will need
o do more co
to oding…
Fo
or example, when you trry to delete an
a Order, yo
ou must first delete the OrderDetails
O s record with
h the same
O
OrderID entrie
es.
But when you etails, you must insert Orrder Record first before OrderDetailss can be
u want to insert OrderDe
nter into the table.
en
Useful Resources
Cynics Software – The Leading Provider in Accounting, POS and Inventory Source Code, build upon
Rapid Application Development Tools from Visual Studio 2005 and 2008.
General Ledger Trial Source Code – Sample source code that demonstrates how we build our system
using RAD tools.