Programming in .NET – part 2 -database creation

Please read the first part at
http://serviciipeweb.ro/iafblog/2006/08/13/Programming+In+NET+Part+1.aspx

The database will be, for Windows forms, Access , and for ASP.NET projects –
SQL Server Express.

Why this choice? Very simple.

For Windows forms, I need something to be easy deployed – and the most easy is
a file based database.

For the ASP.NET application, must be something that can answer queries fast –
and be reliable.(Access it is not a choice)

Moreover, the both databases must have the same standard query language- so
Access and SQL Server are clear as a good choice

How we will generate code to work to both, we will see.

The database will be created in C:\book\BookData folder(please create the
folders).

For those that do not have Access, please download the file from
here

Now start Acces => File = > New = > blank database

Save in the C:\book\BookData with the name book.mdb

I will show you the creation of the first table, leaving as an exercise for the
user the other tables.
As soon as you create DB, you are on the “Tables” tab – and click on “New”

Click on “design view”, then click on OK.

 

Now you can introduce values for as in figure:

 

For making IDAuthor Primary key, right click on the most left side, and then
click Primary Key.

 

After we create other tables, we must link them, to prevent erroneous data
entered in the database( example: a book with an publishing ID that does not
exist in publishing table)

For this, press Tools=> Relationships and select your tables and press OK

Now drag IDBook from Book table to the IDBook from Author_Book

Please select “referential entigrity” cascade update and delete

I let other relationship to the user. Close Relationship and save

Please  download the file from
here
.

Now , because we have finished with database creation, a word about the
organizing of the application.The folder C:\book
will contain:

BookData( mdb files, sql express scripts)
BookObjects( object and database connection)
BookWin( Windows project)
BookDos ( DOS project)
BookWeb(Web project)
BookDeployWeb(deployment Web)
BookDeployWin(deployment Windows)
BookDeploySmartClient(deployment-ul SmartClient)
BookTest

 

On  28 August 2006 will be posted next part when we will wrote some
code in C#.

 

ce mi-a placut la londra

Zborul cu avionul : cum se vad norii din avion – fie ca o patura groasa, alba, fie ca forme extravagante

Speaker’s corner din Hyde Park(si veveritele de acolo)

Satucul calm Hertfordshire

David -care e un pasionat de CSLA

cele 7 pacate ale programarii – multiple interpretari

Mai multe variante la Eric
Cu citeva sunt si eu de acord:
– a inghiti exceptiile
    am avut odata in echipa un programator – despre care credeam ca e bun.
    Dar la un moment dat ,codul lui, desi raporta succes, nu facea ce trebuie.
    Si cind m-am uitat mai jos, in codul de BD, se facea try catch -si atit -nici macar nu se raporta un cod de eroare…
Si trebuia sa imi dea de gindit faptul ca, acum 5 ani, cind el era project manager , s-a implementat in VB6 un layer de conectare la BD IN ACELASI STIL ( bine, nu de catre el, dar orisicit – il avertizasem ca ideea este gresita…). Acel layer de conectare raporta succes din orice operatie… dar ca sa vezi eroarea trebuia sa mai intrebi o variabila publica….

   

Programming in .NET – part 1

This is the first article from a long serie that wants to present the programming in .NET( Windows si Internet)  for the understanding of beginners.
To follow this minicourse, you must have minimum programming knowledge.I consider that you know what a variable is ,that you posess a minimum SQL knowledge and you have heard about 3-tier.
The examples will be made in c# – but you can have in VB.NET or in other language that .NET has . For more languages, please go to :http://www.dotnetpowered.com/languages.aspx
 
What you need is:
 
1. Un PC with Windows ( preferable, XP – not Win 98)
2. IIS for the Internet/Web project. You can verify this in Control Panel => Administrative Tools => Internet Information Services (IIS) Manager.
If not , go to Control Panel => Add Or Remove programs => add / remove Windows components and you will find there.
3. MSDN 2006 May – for tutorials and exemples – free :http://www.microsoft.com/downloads/details.aspx?FamilyID=373930CB-A3D7-4EA5-B421-DD6818DC7C41&displaylang=en
4.SQL Server Express – free : http://msdn.microsoft.com/vstudio/express/sql/download/
4. Visual Studio Web Development Express  free  – pentru web projects – http://msdn.microsoft.com/vstudio/express/vwd/)
5. Visual C# Express  free  – for windows projects- http://msdn.microsoft.com/vstudio/express/visualcsharp/)
6. Optional : ReportViewer Control in Visual Studio 2005 free – pentru local reporting – http://www.gotreportviewer.com/
 
After you download and install those programs , the first application that we made as an example is a project with Databases for indexing the books from the own library.
The project will be only to demonstrate how to program in .NET for Web and Windows.
The priincipal objects of the project will be Book , Author and Publisher
 
The book will have:
Title
Aparition date
ISBN
Publisher ( we suppose the book is published by only one publisher)
 
 
The author will have :
First Name
Last Name
 
The Publisher will have:
Name
WebSite address
 
A Book can have multiple authors and a author can publish several books ( many to many relationship)
A book have one publisher, but a publisher can publish many books
 
What are the request:
– Forms for CRUD ( create, read, update, delete) operations
– Search in database after  : Publisher, Book , Author
– See the objects in relation ( i.e., if a Author is selected, see all the books published by him)
 
Next article will come on 21 august 2006.
 
Until then, I wait your questions at  contact@serviciipeweb.ro

rules to better code – in English

The site
http://www.ssw.com.au/ssw/Standards
is VERY GOOD.
It is a must read.
Some observations, though :

Rules to Better Code
15.Do you have the time taken at the end of a long process?

It’s good to have the time * but to display in another box to force the user to push an OK
It’s better (like you said) to have a status bar for this

20.Do you use interoperability mechanism for COM object?
CreateObject is usefull, in my opinion, in one situation:
You want your program to function with Word 2000 and Word 2003.
You do not want to have 2 programs with 2 references – but you know for sure that the
function you call are the same in both Words.
So – you reference Word2000, create the project, compile, remove New Word.Application with
CreateObject  – and recompile.

33. Do you use Asynchronous method and CallBack when invoke web method?
You can execute the synchronous call to the web service in a background thread ( or other asynchronous method)

Better Dot Net projects
http://www.ssw.com.au/ssw/Standards/Rules/RulesToBetterdotNETProjects.aspx
26.Do you Open your Connection in a Try Block?

quote:
Note:Do not use the ‘using’ keyword in C#. The using keyword is used to declare a scope out of which the connection will be disposed. For the sake of consistancy, we like out VB.NET and C# projects to be as similar as possible. For both languages you should use a Try..Catch..Finally block.   
end quote

VB2005 HAS using(vezi http://msdn2.microsoft.com/en-us/library/htd05whh.aspx sau http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnvs05/html/languageenhancements.asp?frame=true&hidetoc=true) and I prefer using over try catch finally

Rules To Better Windows Forms
http://www.ssw.com.au/ssw/Standards/Rules/RulesToBetterWindowsForms.aspx

26.Do your List Views support multiple selection and copying?
Quote
Make it easier for the user by enabling the “MultiSelection” property of a ListView and providing a right click menu with a “Copy” item that copies to the clipboard.
end quote
Make the same support for CTRL+C

Rules to Better Interfaces
http://www.ssw.com.au/ssw/Standards/Rules/RulesToBetterInterfaces.aspx

33.Do you provide a warning before the program exits?
In 99% percent of cases, the user is right – he really wants to exit. If all documents are saved, then exit.
For 1% of cases that a user makes a mistake, do not bother you with that.

alte reguli – comentarii

Better Dot Net projects
http://www.ssw.com.au/ssw/Standards/Rules/RulesToBetterdotNETProjects.aspx
26.Do you Open your Connection in a Try Block?

quote:
Note:Do not use the ‘using’ keyword in C#. The using keyword is used to declare a scope out of which the connection will be disposed. For the sake of consistancy, we like out VB.NET and C# projects to be as similar as possible. For both languages you should use a Try..Catch..Finally block.   
end quote

VB2005 are si el using(vezi http://msdn2.microsoft.com/en-us/library/htd05whh.aspx sau http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnvs05/html/languageenhancements.asp?frame=true&hidetoc=true) … si folosirea using e preferabila try catch finally …din punctul meu de vedere

Rules To Better Windows Forms
http://www.ssw.com.au/ssw/Standards/Rules/RulesToBetterWindowsForms.aspx

26.Do your List Views support multiple selection and copying?
Quote
Make it easier for the user by enabling the “MultiSelection” property of a ListView and providing a right click menu with a “Copy” item that copies to the clipboard.
end quote
Si de asemenea CTRL+C suport

Rules to Better Interfaces
http://www.ssw.com.au/ssw/Standards/Rules/RulesToBetterInterfaces.aspx

33.Do you provide a warning before the program exits?
Mie chiar nu imi place regula asta. Lasa-i sa iasa… salveaza-le ce au facut …dar nu ii intreba de 10 ori.Utilizatorii chiar vor sa iasa din aplicatie in 99% din cazuri – si pentru 1% nu merita sa tot ii intrebi

Good and Bad at RulestoBetterCode – revised

La adresa 
http://www.ssw.com.au/ssw/Standards/Rules/RulestoBetterCode.aspx
sunt reguli super.

Dar nu sunt de acord cu citeva.

15.Do you have the time taken at the end of a long process?

Da – e bine sa ai timpul …dar sa il afisezi ca user-ul sa mai apese pe un OK – nu vad ca e relevant
Mai bine pui un status bar in care afisezi asta

20.Do you use interoperability mechanism for COM object?
createobject se poate folosi in momentul in care vrei sa fii compatibil cu ORICE VERSIUNI – si stii sigur ca

33. Do you use Asynchronous method and CallBack when invoke web method?
Nu e neaparat necesar sa executi async web method.
Poti sa o executi intr-un background thread … si e tot asyncrona…

Dar inca o data – toate celelalte reguli sunt super!
Merita citite…