Session 1
Dot Net consists of 3 major concepts.
1. Visual Basic.Net
2. Visual C#.Net
3. ASP.Net
VB.Net developed in 2001 by Microsoft.
VB 1.0 origin is developed by Khenmanner Thompson in 1964.
VB 1.0 is developed by Microsoft in 1989. It is much older than java and D2K.
COBOL was dominating even VB 1.0 from 1960 – 86. Market share is 80% for COBOL.
BASIC :- Business All Purpose Symbolic Instruction Code. No technical compilation for BASIC.
Since 1995 BASIC is the starting language. Basic Means BASIC is a business language. Not an application or programming language.
Drawbacks :-
Basic is not Fast because it is Interpreter.
What is interpreter and what is compiler?
Interpreter :- program code will be converted line by line into machine code and then it will execute.
Compiler :- total program will be converted into machine code at a single time.
Note :- A programming language should be simple, accurate and fast.
BASIC means simplicity. VB 1.0 contains GUI facility. But VB 1.0 is not successful. Because of wrong timing by that time DBMS is in dominating position.
DBMS is introduced in 1986 and versions are FoxBASE, FoxPro. But it took 4 years to get market.
So Microsoft launched another version of VB called VB 2.0 but it is also failed.
VB 3.0 was launched in 1993 and started becoming popular. Because started connecting database separately. Means Front-end and Back-end was developed by Microsoft in VB 3.0 from 1993.
Since 1990 there is not front-end and back-end programming method. Only programming language contains database.
Front-end is software which is used for designing screens writing the logic & performing validations. Front_ end is not sufficient for storing data in itself.
Back-end is a type of software used for storing the data permanently.
Note :- To develop any commercial project a combination of front-end and back-end is must.
Front end examples :- VB, VB.net, C#, d2k, Java, Power builder, Delphi.
Back-end examples :- SQL Server, Oracle, DB2, Sybase, Myself, informatica, access, FoxPro.
VB 4.0 was launched in 1994 and made it really popular for Microsoft.
In USA Oracle, VB, D2K was in programming market.
But in India till 1996 there are no programmers for VB in India. Maximum people used to develop programs with COBOL, Dbase, and FoxPro only.
VB 5.0 was launched in September 1997 with some new features like Active X. Active X is basically used in VC++. It is used to develop reusable components.
By that time market share is upto 50%. Major keys are VB and Windows for Microsoft.
VB 6.0 was launched in 1998 with ADO, DHTML, IIS Applications, and Data Reports.
Microsoft wanted to rule the world with internet programming. DHTML, IIS and Data reports are internet features.
But VB 6.0 was failed because Microsoft strategy failed by oversimplification of VB 6.0. New features like DHTML, Data Reports, and IIS features are failed. Over simplification means without declaration we can use variable in VB 6.0
We can use a variable for string or Int or date. No default data type. So it is major drawback.
Java is a programming language developed by Sun Microsystems in 1995.
Java started getting boom in market because
Features of JAVA
1) OOP 2) Platform Independent 3) Free software
Note :- VB 6.0 is Object based language, Java is an Object oriented language.
So Microsoft stopped developing VB language because they can’t recover or alter some major drawbacks.
So they Launched VB.Net 1.0 in 2001. It is not an up gradation version of VB 6.0. Microsoft has remodeled all the features of VB 6.0 from the scratch and introduced VB.Net.
VB.Net is a new Programming approach and it is entirely different compared to VB. It is compact and very powerful language compared to VB 6.0
Note :- Java Drawbacks are No GUI facility , very poor graphical support.
VB.Net Features are :-
1) OOPL 2) Platform Independent 3) Free software 4) Simplicity.
Another language introduced by Microsoft is C# language. C# is similar to VB.Net but syntactically it resembles C language.
Why launched because Microsoft wants to acquire people from Java coding for this purpose they launched C# with C syntax coding. C Syntax is easier than VB syntax.
Session 2
MS.Net :- Dot Net is a combination of languages and technologies which are used to build different types of applications for different types of devises.
Languages are :- VB.Net, C#.Net, J#.Net, VC++.Net.
Technologies are :- ASP.Net, Remoting, and Web Services.
Language :- A software set to be a language, when it has programming features in them. Features are calculations, If conditions, Loops, Functions, Arrays.
Technologies :- Is a type of software which is responsible for executing the program at the server and generating the result for the client. Features are executing program at the server only. It cannot perform programming features.
Note :- A technology is of no use without support of programming language.
ASP.Net :- It is a technology which is used to build dynamic websites.
Website :- Collection of WebPages which provide information at the browser.
Websites are 2 types :- 1) Static WebPages 2) Dynamic WebPages
Static WebPages :- Provide Fixed Information forever. These are designed by HTML and will be Stored in the server. Output will generate at the server and copy of the output will be carried to browser.
Dynamic WebPages :- It will generate a different output every time a user visits the site. Rediffmail.com, Yahoo.com, ICICI Bank and Google.com are examples. Every time the news will be updated.
Note :- Dynamic site may have static pages like Login pages.
Note :- In present market Static WebPages 80% and Dynamic WebPages 20%.
Note :- ASP.Net supports 42 languages and 16 languages are main languages. Most preferred language is C#.
Note :- Competitors for ASP.net in the market is J2EE. But J2EE supports only JAVA.
Note :- A company which develops application only in PERL or COBOL wants to develop a dynamic website then if they want to make it with J2EE then they need to learn JAVA, Advanced JAVA and J2EE. But with ASP.NET they can integrate their PERL or COBOL Language just learning ASP.NET is sufficient.
Applications :- 1) Windows Applications 2) Web Applications 3) Mobile Applications
Note :- Dot Net can be used to develop different types of applications or programs.
Dot Net Features :-
1) Object Oriented Programming (OOP)
2) Platform Independent
3) Free Software
C language runs in different platforms like DOS, windows and UNIX or Linux. Is it Platform Independent?
C Language
|--------------------------------|
Turbo C for Windows & Dos ANSI C for UNIX or Linux
There are two different types of software’s meant for two Operating Systems. A programming in Dos cannot be executed on UNIX and vice versa.
MSDOS 1.0 Developed in 1980. MSDOS 6.22 Last version introduced in 1994.
Windows 1.0 introduced in 1983. It is a simple GUI based operating system. Windows 2.0 another version and Windows 3.1 introduced in 1989.
Note :- By this time actually windows is not a direct OS. We can use Windows as a GUI supported software which will be installed in DOS operating system.
Note :- Microsoft combined MSDOS 6.2 and Windows 3.1 and introduced a Unique OS called Window 95 in the year of 1996.
C language is a platform dependent language even though this program can run in duel operating systems like DOS and Windows, because both are Microsoft products so they will support C language.
Create a C program and run it. The process is……
Compilation :- The process of converting an English written program into machine language is called compilation. Compilation can be performs either with compiler or with interpreter.
1) Compiler :- When a program compiled with a compiler the whole program is converted into machine code at a time and a physical file will be created on the disk.
2) Interpreter :- Program will converts into machine code line by line and physical file will not be created. As a result every time the program should be compiled and executed.
Note :- So interpreter based programs are slow at the time of execution.
Program execution runs by the operating system. If we create a test.c program and compile it, we get test.exe. So if we delete the test.c file then also test.exe file runs because of MSDOS operating system.
Compiler converts a program to machine code it will create some OS instructions in that exe file. These files are related to execution of that program.
Every OS has its own set of instructions. One OS cannot understand the instructions of another OS.
Note :- In C program suppose we use int x that means it will allocate 2 bytes in DOS, But in UNIX 4 bytes. Char C means 1 byte in DOS, But 2 bytes in UNIX. Float in DOS 4 bytes and in UNIX its 8 bytes.
In DOTNET VB.NET or C#.NET both are independent languages.
Compilation is done according to Microsoft standards & instructions. So it doesn’t have OS instructions.
Framework :-
Dot Net framework is a combination of 2 components.
1) Class Library or Framework Class Library.
2) Common Language Runtime (CLR)
Class Library :- It is a collection of classes. Dot Net consists of more than 13000 classes. All those are classified into different categories according to subject wise. Class libraries provide a convenient way to access the classes.
Note :- Class libraries are used to build an application. Without Class Libraries no Dot Net programs can be developed.
CLR :- Common Language Runtime is a program which executes the CIL or MCIL code to machine code with interpretation and create native or machine code then execution will processed and result will be displayed.
Note :- So both Interpreter and compiler will works in DOTNET execution part.
JIT :- CLR will not take place for full execution part. So it will generate a JIT compiler and JIT will execute MSIL to native code.
Note :- When a Dot Net program is compiled the compiler executes test.exe file which is compiled according to Microsoft standards without taking the support of OS. Test.exe file is called CIL code or MSIL code.
Note :- CIL cannot be executed by the OS because it consists of Microsoft instructions. To execute this code CLR is required. CLR is responsible for executing CIL code.
Note :- When execution command is given CLR activates a program called JIT(Just In Time) which interprets the CIL code into native code and then the execution takes place.
Note :- Native code is the code created according to the OS Instructions and standards.
Note :- CLR is not provided for remaining operating systems like Unix or Linux because Windows market is getting down comparing to Linux and other OS`s. So if Microsoft launched CLR for Linux or other OS`s windows share will be get down. Because windows is not open source but Linux is open source.
CTS (Common Type Specification):- It consists of the common types of Dot Net which are required for cross language communication.
CLI ( Cross Language Integration) :- Two different languages can communicate smoothly with this CLI.
Note :- Every Language in Dot Net consists of their own data types. To communicate with different languages Microsoft introduced common Data types which can be used by any language.
Memory Management (MM):- Microsoft has introduced a feature called automatic memory management which related the memory occupied by the objects when they are no longer required in the program.
Session 3
Object Oriented Programming :- (OOP)
Languages are two types.
1) Procedure oriented languages.
2) Object oriented languages
Procedure oriented Programming languages are BASIC, COBOL, (these two are Complete procedure in 1960`s) Pascal, C, Fortran.
Object oriented programming languages are from 1980`s. C++, VC++, VB.Net, C# and Java.
Procedure oriented Programming drawbacks :-
1) Very lengthy programming.
2) High memory consumption.
3) No code reusability.
4) No security for data.
In C we have global and local variables but in COBOL only global variable. Functions not available in COBOL.
Object oriented programming was introduced especially to overcome these problems.
Features of OOP :-
1) Classes
2) Objects
3) Inheritance
4) Polymorphism
5) Encapsulation
Object :- Instance of class is nothing but an Object. It’s a entity. Anything that could have unique identity is called Object.
Class :- The origin from where objects are produced is called a class.
Note :- Without a class an object doesn`t exist. A class alone is no use without having objects. So a class and object are interrelated or interdependent.
Ex :- In C program int s means int is a data type and s is object. Means int is a class of numeric type.
Inheritance :- It Is a feature by which one class acquires properties of another class. Creating new classes from an existing class. Derived class can inherit some or all the traits from base class. A class can inherit properties from more than one classes or more than one level.
Inheritance provides cool reusability.
Single inheritance:- Deriving from only one base class.
Multiple Inheritance:- One derived class with several base classes.
Hierarchical Inheritance:- more than one class may inherit the traits or methods of one class.
Multilevel Inheritance:- Deriving a class from another derived class.
Must Inherit:- A class which has a must inherit keyword indicates that methods to be implemented by derived class.
Polymorphism:- Which allows multiple futures will be developed by using a common name.
In C we cannot use same function name with different objects.
In Dot Net there are 13000 classes, 90000 functions, 80000 properties. Out of 90000 functions nearly 22250 functions are overloaded.
Note :- Multiple functions can be developed with the same name. the number of arguments is type of arguments is different. We cannot have two functions with the same name, number of arguments and type of arguments.
Note :- C# symbolically equals to C language.
Ex :- Add(int x, int y) { Add(int x, int y, int z) { Add(float x, float y) {
Return(x+y); } return(x+y+z); } return(x+y); }
Operator Overloading :- it is a feature which allows a single operator to perform multiple tasks. (+, -, *, /). It performs the tasks based on the operator specifications.
Ex :- 5+3=8 “A”+”B”=AB 5+”A”=runtime error.
Operator Overriding :- Overriding is the process of overwriting the methods and properties of base class in a derived class. In Base class we use Keyword :- Overrideble, in Derived class : Overrides.
Encapsulation :- The process of binding together data and members is called encapsulation.
Structure :- is a user defined data type. (It is only a data type. We can’t assign values to it). Different data type values can be brought into a collection is called structure.
Note :- In C language like int, structure is a data type. Memory is allocated according to structure data type.
Note :- In C++ structure named as Class. A class contains variables and functions. Class is similar to structures in C language but we can use functions also in C++ which is not possible in C.
Note :-In Dot Net a class contains variables, functions, properties, events also.
Ex :- In C language In C++ language
Struct std { class std {
Int no; char name[25]; int total; }; int no; char name[20]; int total; };
Main() { Main() {
Int x; char name[20]; struct std s; Int x; char name[20]; std s;
s.no=10; s.name=”sri”; s.total=25; } s.no=10; s.name=”sri”; s.total=25; }
Note :- Dot Net 3.5 is only framework. It contains Class library and CLR only. Dot Net framework is the actual software provided by Microsoft as free of cost. It can be downloaded from the internet and used.
Note :- Visual studio 2008 or 2005 or 2003 is GUI based editor where we can develop programs very quickly.
Framework available editor by that time
Dot Net 1.0 Visual Studio
Dot Net 1.1 Visual Studio 2003
Dot Net 2.0 Visual Studio 2005
Dot Net 3.0 Visual Studio 2005
Dot Net 3.5 Visual Studio 2008
In Visual studio there are two parts.
1) Express Edition. ( Learning purpose)
2) Enterprise Edition. (Commercial purpose)
Note :- Visual studio express edition is the free software which can be downloaded from internet.
Note :- Visual Studio 2008 can be used with different versions of Dot Net. We need to install frameworks of different versions in your system.
1) Console Application ( Command prompt)
2) Windows Application (VB.Net or C#)
3) Web Applications (ASP.NET)
4) Mobile Applications ( ASP.NET)
Note :- VS 2005 onwards SQL Server express edition is also included in installation.
Hardware Requirements :- Software Requirements
Processor :- 700 MHZ or above. Windows XP 2000 Professional (1999)
RAM :- Minimum 512 MB SP2 SP6
Hard Disk Capacity :- 10 GB or Above. IIS 5.1 IIS 5.1
Note :- MSDN Provides a complete documentation for Dot Net.
VS Dot Net occupies 2 GB excluding J# and VC++. Including it is 2.6 GB.
Session 4
Console Application :-
Class
public static void Main () {
System.Console.WriteLine(“ Welcome to World of First Program “);
} }
System – your system pc.
Console – Any standard input or output device referred.
WriteLine – Output device referred by Console.
Compilation :- E:\Siva\csc first.cs (Creates a file called first.exe)
Execution :- E:\Siva\first (or) first.exe.
Note :- A namespace is logical collection of classes.
Note :- For namespace or class or function 1st letter should be in caps.
Note :- In case of c# it may consist of 2 or more words then first letter of every word should be capital.
String :- Set if characters which are entered by keyboard.
Read() :- it is a function which accepts the input value from keyboard and returns ASCII value.
ReadLine() :- This is a function which accepts string as an input and returns the string.
Int32.Parse :- it is a class and Parse is a function which converts the string into integer format.
Loops are :-
1) While 2) Do While 3) For 4) Foreach
While :- as long as condition is true loop will execute the statement.
Do While :- Loop will be executed compulsorily for at least one time because it will enters directly into program and then it will check the condition.
For Loop :- for(
Class :- A class is just like structure of C language. Like structure in C, classes also have variable, functions, properties, events.
Note :- If we call anything inside a class that is an object.
Note :- If we call in structure or data type that is variable.
Note :- By default variables are private as access modifier.
Access Modifiers : 1)Private 2) Public 3) Protected 4) Internal 5) Protected Internal.
Private : Private members cannot be accessed from outside the class. They can be accessed only with
Public :- These members can be accessed from outside the class after creating an object.
Note :- There are three different people involves from the point of creating a class to till the execution of the program. In real time environment classes will be developed by one programmer and they will be handled by the other programmer.
Note : In console applications we need to create classes and then we will create objects. In GUI environment programs there are 13000 predefined classes available.
Constructors :- it is similar to that of function except the following differences.
1) Constructor name and class name is always the same.
2) A constructor doesn`t have any return type(not even void).
Similarities with functions : A constructor can take arguments. It can be overloaded.
Purpose of Constructors : It is mainly used to initialize an object with certain values.
Behavior of Constructors : It can be executed automatically whenever an object is created.
Destructors : It is similar to a Constructor but it will prefix with “ ~ “ symbol. A destructor executes automatically whenever the object released from the memory.
Purpose of Destructor : It is used to clean memory occupied by the objects when they are no longer required in the program. It cannot be overloaded.
Note : Every class consists of a constructor called default constructor. If a class doesn`t has any constructor by the programmer then default constructor will be executed. It is a null constructor and doesn`t take any parameters. Once we create a user constructor then default will not work.
Session 5
Properties : 25% Dot Net deals with properties. A property is similar to that if a variable in terms of usage. It is much more than a variable in terms of behavior.
Note : property can be made as write only or read only. A property can also contain certain logic which can be executed whenever a value is assigned or read.
A property consists of 2 blocks.
Set : Whenever a value assigned to property “ Set “ block will be executed. A value assigned will be stored in a predefined variable called Value which exists in the Set block.
Get : Whenever a value read from the property “ Get ” block will be executed, which returns the value assigned to the property.
Writeonly Property : In case of writeonly properties a property can be used only to assign a value but not for reading the value. Writeonly property contains only “SET” block and not the “GET” block. In writeonly property value can be read by other members of a class.
Reading property : Opposite to Writeonly property. In case of readonly property it can be used to read the value but cannot write. This property contains “Get” value. In Readonly property writing may be performed by other members of class. These properties are used when returns sum fixed values.
Static Members : Static members can be accessed directly without creating objects. They can be accessed directly with the reference of class name. It is useful where memory allocation is not required.
Note : Static members are used when object creation or memory allocation for an object is not required. Ex. Color class in Dot Net framework. No need to allocate memory.
SESSION 6
Main project is called as solution. Remaining modules are called as projects.
Solution project and forms are the actual files which will be stored in the disk. Each having separate extension.
Solution - .sln.
Projects - .csproj.
Forms - .cs.
Solution consist of project names not physical files, which contains project names and paths. One file cannot contain another file in it.
Solution, project and form stored independently as different files on the disk. But from visual studio environment they will be represented one inside another. It is held by logically.
Note : With a project name specified, a folder, a solution and a project will be created.
Note : Whenever a new project is created a form also will be created with the name form1 by default. But other forms can be added if they are required.
A Form is surrounded by 7 different windows and bars.
1) Menu Bar – Which is located at top.
2) Tool Bar – below menu bar.
3) Tool Box – Consists of controls. A control is a GUI based component which has specific appearance and usage.
4) Properties Window – This contains fields to assign attributes or values to controls.
5) Solution Explorer – Contains projects, forms, and configuration files information.
6) Server Explorer – Contains connections and database related information.
7) Component Tray – This tells the information about every control.
A control is basically a class but it has a graphical appearance. Every control provides properties. Properties are used to provide settings to the control. F4 is shortcut.
Label : is used for displaying text on the form. Label label1=new Label();
Properties :
1) Text – used to display text on the label.
2) Font – For changing font style.
3) Backcolor – used to set backcolor.
4) Forecolor – used to set font color.
5) Autosize - True/False property. If true automatically label size will be adjusted based on text.
6) Textalign – Is used to set the position of the text on the label. Will not work with autosize property.
7) Image – used to display image on the label.
8) Image align – to set position of the image.
There are two ways of selecting images.
1) Local resource – Images selected by selecting path of image will be referred.
2) 2) Project resource – image itself copied into the project folder. The image is copied under a special folder called “resources” which will be created in the project folder.
TextBox : it is used to enter the text at runtime.
Properties :
1) Text – used to display text on the.
2) Font – For changing font style.
3) Backcolor – used to set backcolor.
4) Forecolor – used to set font color.
5) Textalign – used to align text.
6) Maxlength – Specifies maximum no characters to be entered in the textbox. 32767.
7) Password – Specifies the character that should be displayed as a password character.
8) Multiline – If it set to true, displays the text in multiple lines. Password character doesn’t work when multiline is set to true.
9) Scrollbars – none, horizontal, vertical, both.
10) Locked – True / false. If true locks the position of the control on form.
11) Wordwrap – True / false. If set to true brings the text to the next line whenever it reaches the end.
12) Readonly – True / false. If true, text cannot be entered on the textbox. Used only for reading purpose.
Button Control : used to execute certain code whenever a user clicks on the button.
Properties :
1) Text – used to display text on the button.
2) Font – For changing font style.
3) Backcolor – used to set backcolor.
4) Forecolor – used to set font color.
5) Textalign – used to align text.
6) Image – used to display image on the label.
7) Image align – to set position of the image.
Events are occurrences of particular control. Not available in C language.
Button _ click(){
Close();
End.
Note : Public partial class Final : Form (:: predefined class). Every form is a class. Every form contains two files.
1) Form.cs 2) form.designer.cs
These two files are implemented as partial classes.
Form1.cs is consisting of code written by programmer.
Form1.designer.cs consists of code generated by windows in the background.
After partial class remaining code is one constructor and one function.
Name spaces are logical collection of classes.
Online help will be provided when you write a code for predefined controls that small window is called “intellesence”.
Checkbox : it is used when user has two choices and 1 is right answer.
Properties :
1) Checked – true / false
2) Text – used to display text on the checkbox.
Radiobuton : useful when a user has two or more choices and 1 is the right answer.
Note : Out of all the radio buttons which are created in a form only one can be selected. Radio buttons cannot be used for two different purposes.
GroupBox : This control can be used when a control has to be used for two different purposes. A Groupbox can be used for any type of controls like Radiobutton. It is also called as container.
Any control which contains other controls is called a container. A form is also called as container.
ListBox : It is used when user has a choice of large number of items and one has to be selected.
Properties :
1) Items – To specify the list of items in a Listbox.
2) Sorted – True / False. Arranges all the items in alphabetical order.
3) Selection mode – None, One, Multisimple, Multiextended. We can select more than one item.
4) Multicolumn – Items can be available in multiple columns.
Note : Every item will have index numbers from 0 to n…. Whenever item selected item index number will be changed. whenever index number is changed this event will fire.
Session 7
Checkedlistbox : Similar to Listbox. But every item will be displayed along with a checkbox.
Properties :
1) Add Items
2) By default it will work with multiple selections.
3) We need to select item with 2 clicks by default. We can make it immediately if we set property “Checkonclick as true” then it will select for single click.
ComboBox : It is a combination of list and textbox.
Properties :
1) Add Items
2) Sorted
3) Maxdropdown(display limited items)
4) Dropdownstyle
Combobox allows only 1 item to be selected.
PropertyDropdownstyle : 1) Dropdownlist – we can’t enter or type text in combo.
2) Simple : No dropdown symbol available. We need to select height for it.
Picturebox control : Is used to display images on the picturebox.
Properties :
1) Image – select image
2) Sizemode – normal, Autosize, stretchmode: image will be adjusted within control margins.
Messagebox : it is a class and show is function which is used to display a message in a small window in the centre of the form along with an ok button. It can be used to provide any conformation or information or a winning to the user.
Messagebox.Show(“Welcome to DFI”,” DFI Infotech welcomes you”);
Note : a MessageBox consists of 6 different of buttons.
1) OK (Default)
2) OK, Cancel
3) Abort, Retry, Ignore
4) Yes, No, Cancel
5) Yes, No
6) Retry, Cancel
Note : We can assign Icons also to Messages.
Load Event : this event fires whenever the form is executed.
TextChange Event : this event fires whenever there is change in the text box occurred.
Leave Event : This event fires whenever the cursor comes out of a textbox.
Enter Event : Fires whenever the cursor enters into any textbox like it is opposite to leave event. The Leave event of one textbox is equals to the Enter Event of the next Textbox.
Note : Execution means we will give some commands to execute. But fire means execution occurs automatically. By default Microsoft provided events for every control.
Note : Once we click the leave or Enter events, 2 operations will be performed. One event is registered in Designer file. It is nothing but declaration of event and another event function is created in .cs file. So If we delete event in code window that’s not sufficient, still your program display error. We need to delete this event function in designer file also.
Data Validation : Validations used to check the data weather it is properly entered or not.
3 types of validations
1) Numeric Validations : we must use leave event for this validation.
2) String Validations
3) Date validations
Note : || operator used as “or” operator. Every string in Dotnet is a object.
Textbox1.Text must be treated as a single object of string. An object may consist of properties and functions.
SESSION 8
String functions
Every string in Dotnet treated as an object. An object may consist of properties and functions.
Txtname.Text.Leangth
| |
String Property.
Textbox1.Text.Length.Tostring() : define the total no of characters of that string.
Textbox1.Text.Trim() : removes the unnessacery spaces which are available at begin & end of part.
Textbox1.Text.ToUpper (): converts string from lower to upper.
Textbox1.Text..ToLower() : converts string from upper to lower.
Textbox1.Text.Substring(4,3): returns specified no of chars from specified index position of string.
Textbox1.Text.IndexOf(“s”) : returns the index number for first occurrence of this char. It will return -1 if mentioned char is not available in the string.
KeyPress : this event fires whenever a user press the key in that control.
Note: MessageBox returns only string type so we want to display numeric data we need to convert it into chars.
Note : KeyPressEventArgs is a class and ‘e’ is an object. Whenever a key pressed the information of the key will be stored in the object called ‘e’.
e.KeyChar : Keychar is a property which returns the character pressed by the user.
Handled : is a property when set to true delete the character from the keychar property.
KeyDown & KeyUp : This events fires when any key pressed by keyboard including function keys and arrow keys also. Keypress event will fire only for those keys which has an appearance on the textbox.
Arrays : String[] s = new String[5];
System collections :
1) ArrayList
2) HashTable
3) SortedList
4) Stack
5) Queue or heap.
ArrayList : It is a class which is similar to that of an array but that can represent values of various types. Note : It will accept multiple datatypes. The size of Arraylist is not fixed. Any no. of elements can be added. It does not accept index no for elements. The elements can be added or removed at runtime.
Count : is a property which returns the number of elements in an Arraylist.
Capacity : is a property which returns the total no of elements for which memory has been allocated. By default memory for 4 elements will be allocated. When the 5th element added another 4 elements memory will be added to Arraylist.
TrimTosize() : is a function which removes extra memory which allocated in the object but not used.
Foreach : is a special for loop which is executed for each and every item that exists in the object(ArrayListObject). Every time the loop executes, it reads one value from ArrayList and returns to the specified variable.
Sort : Arranges all the elements in alphabetical order.
Reverse : reverse all the elements of an ArrayList.
Hashtable : These are similar to ArrayList. It represents all the values in the combination of Key and Value pairs.
DictionaryEntry : it is a class which represents the data in combination of key and value which is similar to that of Hashtable.
SortedList : It has the feature of ArrayList and Hashtable. SortedList represents all the values in sorted order.
Session 9
Namespaces : it is a logical Collection of classes. It provides a convenient way to access classes in Dotnet.
More than 13000 classes available in Dotnet and all those classes belongs to different Namespaces.
Logical collection of Classes.
ADO.NET : It is a microsoft technology used for interacting with the database. ADO.Net is a common technology used for all Dotnet application.
Database : It is a backend software where we can store data in this software. It contains one or more tables.
Features :
1) Creation
2) Retrieval
3) Modification
4) Deletion
Retrieval : basically 3 types.
1) All records 2) Few records 3) Single
Database mainly containg these 6 consepts.
Data Access Components : 1) ODBC 2) OLEDB 3) ADO 4) ADO.Net.
ODBC : Set of application program interface (API) functions that can be used to connect verity of databases.
OLEDB : OLEDB is an API that is based on the Component Object Model. OLEDB is a lower level database interface. DataSource may be in any format like Oracle, SQL Server, MS Access and Excel etc.
ADO : Is a method of data access developed by Microsoft. It’s a collection of objects that can be used to access data. ADO connects to database through OLEDB provider.
ADO.NET : This component introduced in Dot Net Framework. It offers scalable, uninterruptible data access because of the use of XML for transmitting data between different application layers. XML acts as basic format for transferring data in ADO.NET. XML can access traditional database like SQL Server or accessed using OLEDB or ACCESS.
Note : ADO.Net is a Active Data Object. ADO & ADO.Net are different technologies providing different architectures for interacting with databases.
ADO .NET Advantages :
1. ADO .net does not support on continuously live connections.
2. Database interactions are performed using data commands.
3. Data can be cached in Datasets.
4. Datasets are independent of data sources.
5. Data is persisted as XML.
6. schemas define data structures.
SQLClient OLEDB
SQL Connection OLEDB Connection
SQL command OLEDB command
SQL DataAdapter OLEDB DataAdapter
SQL Reader OLEDB Reader
SQL Parameter OLEDB Parameter
SQL Transaction OLEDB Transaction
Basic Components in ADO.NET is 2 types : 1) Dot Net Data Provider 2) DataSet .
DotNet DataProvider : It provides the interface between data source and application. Data providers are available as objects.
Data provider has 4 components. : 1) Connection 2) Command 3) Data Reader 4) Data Adapter.
Connection : Connection is a class used to establish connection between application and database.
DML (Data Manipulation Langugage) : Any sort change made to database is called manipulation.
Command : Command object used to retrieve and manipulate data in the database. It uses SQL statements to retrieve data, but it can deal with only a single record at a time.
Data Adapter : This method used to fetch the values from the data source to the Dataset and also to update the data source with the data in DataSet. So it always requires Dataset.
Fill Method : In data adapter class this object used to fill the DataSet.
Data Reader : This component is used to get the read only and forward only data from the data source when ever Sql command used.
SQL Parameter : is used to parse the parameter to a stored procedure that exist in database.
SQL Transaction : Is used to commit or rollback the SQL statements performed on the database.
DataSet : It is a independent class, which can represent entire relational database in memory, complete tables, relations and views. DataSet designed to work without any continuing connection to the original data source. DataSet contain 1 or more tables and information about relations and constraints.
Note : When a select statement applied using DataAdapter, the Query is copied into Dataset and stored in a datatable in XML Format. As a result any changes remains to Dataset will not effect to orginal database table. And vice versa. It is a discunnected model architecture.
Note : In VB 5.0, VB 6.0 Microsoft used a recordset concept to retrive the data which always maintains an active connection with database. So ADO works with references of data not copy of the data.
Data Table : Data in the DataSet is stored in the form of Data table.
Hash table : This is used to access elements by a unique key in .Net Collection class.
Dataview : It is a presentation layer for the data that is stored in the data table. It provides a customized view of data table for sorting, filtering, searching. Dataview allows data binding for Winform controls.
Dataview Manager : It works like data view. It shows a customized view of DataSet and also stores relations.
Data Binding : Process of tying control of the application to any column or row of data table. Association between two controls is possible using data binding. We can associate DataSet and Textbox.
Data Binding 2 types : 1) Simple Binding 2) Complex Binding
Simple Binding : Only single value from DataSet can be bound to a single control.
Complex Binding : Control is bound to a complete DataSet instead of single value. Only Datagrid & ComboBox supports.
SQL Server Datatypes :
Datatype Memory contains Max value allowed
Trim int 1 Byte 0-255
Small int 2 Byte + 32767
Big int 4 Bytes 2470000000 approximate
Numeric/Decimal
Money 8 Bytes
Varchar
DateTime 8 Bytes 31-12-9999
Note : In SQL server every database contains 2 files.
.mdf File (Microsoft datafile) .ldf file(datafile)
Note : .mdf file is actual file which stores the data.
Session 10
Cnst : is a string variable which stores connection details.
Cn : is a connection object and this step allocates the memory for the connection object and connection details are passed as arguments to the constructor of the connection class.
Open : is a function which establishes connection to database, based on the arguments passed to the connection object.
Cmd=new command(st,cn) : this line creates a command object and passes 2 args to connection. 1st org the statement to be executed, 2nd specifies where it should be execute.
ExecuteNonQuery : is a function which executes the statement passed to the command object.
Execute Reader : is a function which executes the select statement and returns the result to a dataReader object. Datareader object represents only single record at a time.
Dr.Read() : Read is a function which moves the pointer to next record whenever it is referred. If record exist in a pointer, pointer position returns “true” else returns ‘false”.
Dr.close() : It is function which disconnects the data reader with a command object.
Cn.close() : Datasorce connection will be disconnected.
da=new SQLAdapter(st, cn); - da is a data adapter object and this will create adapter object and passes 2 arguments to constructor. One argument specifies the query to be executed, 2nd argument specifies the connection where it should be executed.
Ds=new Dataset(); - This statement creates a dataset object which stores the result generated by data adapter.
Da.fill(ds, “test”); - Fill is a function of adapter object which executes select statement and copies result generated into the dataset. In Dataset the result will be stored in a data table.
Datagridview1.Datasource = ds; - Datasource is a property of grid control which is used to assigned to Dataset.
Datagridview1.DataMember=”test”; - Data member is a property of grid control which is assigned to Datatable.
Session 11 – Stored procedure
Stored Procedure : This is a program in SQL Server which is stored as a part of the database. It can consist of one or more SQL statements. Stored Procedure can be called from a frontend application like from VB.Net, C#.Net or ASP.Net. Stored procedures are intended to reduce the number of roundtrips that take place between client & server and improves the performance of an application.
use DFI
go
create procedure sampleprocedure @empno smallint, @empname varchar(25), @dob datetime
as
begin
insert into emp values(@empno, @empname, @dob);
end
To execute Stored procedure : sampleprocedure 101, ‘sravan’, ‘10/02/2001’
Session 12 – exception handling
Exception Handling : It is response to an abnormal or unexpected condition occurring in a program. It is used to avoid the runtime errors generated in a program. Basically Errors are 3 types.
1) Compilation Errors 2) Runtime errors 3) Logical Errors
1) Compilation Errors (Syntax Errors) : these are raised at the time of compilation of a program. These errors occur because of syntactical mistakes or spelling mistakes.
2) Runtime Errors : These Errors occurs at runtime. They arise when a user tries to perform certain impossible tasks.
3) Logical Errors : These are the most dangerous errors which don’t show the error either at compilation time or runtime. Error exists in the logic of the program. It should be detected & rectified by the programmer.
Note : Exception errors deals with runtime errors. Whenever a runtime error occurs, the program execution gets terminated abnormally. Exception handling avoids the abnormal situation and provides a systematic end to program.
Exception Handling keywords :
1) try 2) Catch 3) Finally 4) throw
Try : try block is used to detect the runtime errors that occur in a program. All the programming logic should be written with in a try block. Whenever a runtime error occurs within try, it will detect the error and sends the error info to catch block. A try block can have multiple catch blocks.
Catch : Catch block is used to receive the runtime errors from try and provides the systematic end to the program.
Note : If an error from outside try then it will not detected by try block, and one runtime error displayed on the screen. There is no runtime error, then catch block doesn’t execute.
Exception types :
1) Dividebyzero exception
2) Nullreference Exception
3) SqlException
4) Format Exception
5) RuntimeException
6) ThreadException
7) SocketException
Note : Exception will not bother about how to rectify the error but it will try to avoid that error only.
Ex.Message : It’s a property which returns the error message generated by the programmer.
Ex.Stacktrace : This property returns details of the error.
Ex.ToString() : This function returns complete information of the error including exception name, stack message and error details.
Note : Every runtime error in Dotnet is provided with an exception class which deals with the error. Exception is a super class which is inherited by all other exception classes.
Finally Block : This block gets executed irrespective of the behavior of the error. If a runtime error occurs finally block executes after the catch block. If there no runtime error, finally block executes after the try block.
Throw : it Is used to generate the error manually through code. Throw block perform the same task as a try block but is conducted by programmer. It is useful when a programmer can recognize the occurrence of the error before it actually occurs.
Session 13 - Multi threading
Multithreading : It is a feature which allows multiple programs to be executed at a time. “executing concurrently is called multithreading”.
Multitasking is a feature where user can work with multiple softwares. A task consists of 1 or more number of threads.
Multithreading is used to execute the program faster than the normal execution. To reduce the idle time of the processor or CPU we use multithreading.
Multithreading improves the performance of the program by reducing idle time of the server. While external device performs a task, the idle time of the CPU can be used to execute other tasks of the program.
System.Threading : it is a namespace used in Dotnet which consist of set of classes.
Note : By default crossthread communication is not allowed in Dotnet. Means one object created by one thread cannot be accessed by another thread. To allow such access, a property required, which is called “checkforillegalcrossthreadcalls” should be set to false.
Thread property : It is a feature to specify the importance given to the thread. We have 5 priorities.
1) Highest 2) lowest 3) normal 4) above normal 5) below normal.
Note : A thread with highest priority is provided maximum amount of time for execution and very little idletime or sleep time.
Note : A thread with lowest priority is given maximum sleep time and very little time for execution. By default all the thread provided with normal priority.
Synchronization of thread : It is a feature where only one thread executes at a time. Even if multiple threads started second thread started execution only after the completion of first thread.
Ex: check withdrawal and ATM withdrawal at a time. Real problem in 2000 at Gujarat.
Note : Synchronization is applied to execute the program in a secured manner. Irrespective of priority, threads will work.
Session 14 – DialogBoxes
RichTextBox : It is similar to textbox but it has more features like we can enter unlimited contents. And contents of RTB can be saved on the disk in the form of a file.
Dialog Boxes :
1) SaveFileDialog : It is a control which displays SaveDialogBox. It will be placed on your form with in a special area called component tray. It is a place where invisible controls are stored.
2) OpenFileDialog : Is a control displays Open Dialog Box.
3) ColorDialog : Displays the Color Dialog Box.
4) FontDialog : Displays the Font Dialog Box.
MenuStrip (Main menu in old version called in 1.1) : whatever controls provided to programmers, those controls can be provided to end user.
Properties : Dock
Note : We cannot run one form from another form directly. So we need to create a object for the class form.
Note :if we show in showdialog we can’t move curser or we can’t go for any other form or control.
Note : We can assign Hotkeys and shortcut keys to menu strip. Hotkeys are combination with “Alt” key which contains “_”.
MenuItem Property :
1) text - &Account open Form 2) Shortcut keys : ctrl+A 3) Checked : T/F
4)Enabled : T/F 5) Visible: T/F.
We cannot set short cut keys for Menu. It is possible only for Menu Items.
Session 15 – Other controls
Toolstrip ( Toolbar in old versions) :
Tool strip control consists of 1 or more no of buttons. It can also contain other controls like textbox, label, Combobox etc.
Properties :
1) Text 2) Image 3) Displaystyle 4) Textimagerelation 5) tooltipstrip
Statustoolstrip control : This control appears by default at the bottom of the form. It consist of 1 or more labels. It is used to display the status of the form or some info on the form.
Timer Control : It is used to execute certain code automatically at regular intervals without disturbing main program.
Properties : 1) Interval 2) Enabled
Timer_Tick(----------) {
Toolstripstatuslabel1.Text=Datetime.Now.ToString();”
}
Note : Tick event automatically gets executed based on the interval specifications.
MDI Forms :
These are two types of forms in Dotnet. But default is SDI.
1) SDI – Single Document Interface 2) MDI - Multiple Document Interface
Note : MDI allows the users to interact with multiple forms at a time.
Properties : IsMDIContainer-true.
Note : This property makes the current form as MDI Form and is also called as MDI Parent Form. Any form that is opened with in MDI form is called as MDI Child Form and child form will be executed with in parent form.
Ex: Form2.MDIParent=this;
Note : We can align the forms which are opened with in a MDI form.
1) Vertical 2) Horizontal 3) Cascade
Tab Control : It is a container which consist of 1 or more no of tabs. We can treat each and every tab as a form. We can move to another tab in runtime.
Properties : Tabpages
Session 16 – Class Library
Class Libraries : these are another type of projects in Dotnet which are used to develop reusable components.
Ex : Date Validations, Number Validations etc.
Note : Class library project consist of 1 or more classes. This project does not have any GUI appearance. It only consist of code which can be used for different other projects.
Two Methods can be used to work with Class Libraries project.
1) Creating a new project in with new solution. 2) Adding New project to existing solutions
Note : A class library cannot be executed directly on a window. A class Library Project to be accessed to another project should be built into dll. Build. Filename ->Bin->debug->file.dll.
Note : Every project in Dotnet produces either .exe file or .dll file. .Exe file will execute directly. Dll should be added as reference to other projects and then access.
Session 17 - Assemblies
Assembly : It is a basic unit of application deployment and versioning. Also we can call “Building block of DotNet application”.
Note : Any file with an extinction of exe or dll is called an assembly. Without assembly DotNet cannot exist. Even DotNet software has been released in the form of an Assembly.
Note : Basically an exe or dll file consist of a namespace and in that we have different classes. In that classes we have functions, properties, variables.
Note : Any program will create a exe or dll file. Nothing but building blocks of a program.
Assembly consist of
1) Manifest 2) CIL Code 3) Type Information 4) Resources
Manifest : Consist of information of an assembly like assembly name, version no, culture(language) used in Assembly. Default language for assembly is American English.
CIL : Represents the code compiled by compiler according to Microsoft standards. Logic or code of program is taken care by CIL.
Type Information : Consist of list of types used in a DotNet program. VB to C# or Java to C# like.
Resources : Consist of images which are part of DotNet application. But not included in CIL code.
Note : Assembly can consist of single or multifile. Console application is a single Assembly. Windows is a multifile.
Note: Assembly can have only 1 entry point where execution starts. Winform application has only 1 main function which is program.cs.
Assembly versioning : Is a feature which allows to different versions of same component to exit in a single machine and in a single location.
Note : 2 versions of same component can exist in the same machine in a single location. So we can install all the versions of DotNet and we can run applications of different types.
Note : DotNet framework contains all the classes as DLL’s. Microsoft provided a special folder called assembly where DotNet components are registered. This is special folder where different versions of DotNet components are installed.
Assemblies are 2 types.
1.Private assembly : can be accessed independently in a single application only. These can be worked alone to a single application. Ex: console applications we can run directly .exe alone because this is an assembly.
2.Shared assembly : these are nothing but .DLL’s where we can use it in multiple applications. A program which contains functions and classes without Main function and can compiled and saved as .DLL is a shared Assembly.
Strong Named Assembly : A shared Assembly along with a private key and version no is called as strong named Assembly.
Public Key : it is also called as strong name key which is 1024 bit code which provides security to an assembly. Version no provides unique identity to the Assembly. This cannot be tampered or corrupted or modified or altered. Like by virus or tremens they will effect mainly on DLL’s and .exe’s only.
Note : Microsoft released all the Namespaces as strong named Assemblies. Secured because it is in 1024 bit code.
GAC : Machine wide independent location where all the strong named Assemblies are registered. It is represented with a folder called Assembly in the OS folder. Ex: c:\windows\Assembly.
Note : Version no is a 4 part no which should be provided by author or programmer or creator. Ex. Version No : 1.0.3.2. In this version no 1 =Main Version, 0=Minor Version, 3=Build Version, 2=Debug version.
Debug version : purely for company or programmer who created version no. one documentation file will be attached when new version was created and in documentation they provide the problems and modification of previous version. Like 1.0.0.8 to 1.0.0.9 ->1.0.0.15.
Build version : Once the complete problems of previous version rectified then author build the version and change the Build version no like 1.0.0.15 to 1.0.1.0.
Session 18 - Remoting
Remoting is a Microsoft technology which is used for communication between different machines which are running on same platform and using same language. Remoting is useful in 3 tier applications when different clients need to access a common language in a program.
Remoting : A client machine invokes the function at a server and server executes the function and returns the result to the client.
To develop Remoting application 3 different programs need to be developed.
1) Server program : which consists of classes.
2) Client program : use to make a call to server to invoke function.
3) Register program : This program is used to load the server program into the memory.
Port No : It is an address in the servers memory where programs can be loaded. Every system has port no’s which starting from 0 – 65535. From 0-1024 reserved for operating system. From 1025 – 65535 is available to users. At one port only one program can be loaded.
ARCHITECTURE OF SENDING A REQUEST TO SERVER FROM CLIENT
Client Server
Proxy
Message(classes & Functions) Message(classes & Functions)
Formatter Formatter
Terms used in Remoting :
1.Remote host : It’s a server application which is used to listen to the request made from the client.
2.Channels : It’s a program used for communication between two machines. Channels are 2 types. TCP & HTTP.
Note : TCP Communicates in a binary format so it is much faster. HTTP communicates in a text format.
Formatter : Is used to convert the message into a specified format. These are 2 types Binary and SOAP formatters.
Binary Formatter : Converts to binary format. TCP channel uses this formatter.
SOAP Formatter : Converts to text format. HTTP channel uses this formatter.
Message : A program consist of complete information about the functions which are to be invoked. Before leaving from client message should be filled with these details.
Proxy : It is a program at client side which creates a message when a client invokes the functionality at server. It will not work in “server to client response” concept.
2 types of objects that can be created at the server.
1) SingleCall : In this method for each and every request made from client, one object will be created.
2) SingleTon : In this method a single object is created to process all the requests made by client.
Note : when a request performed to server, in server port no invoked and in that port , class will be invoked. Per 1 request we use one SingleCall.
Session 19 - File stream or IO Stream
File Stream : it is used to get hold of the file on the disc.
Stream Writer : It is a class used for writing the text into file.
Stream Reader : Used for reading the text from file.
Note : In hard disk data is stored in aluminum cylinder which rotates with a proper speed 5400 rpm or 7200 rpm.
Note : Data written in streamwriter is stored as object.
Session 20 – Setup and Deployment
Note : Setup & Deployment is a project in Dotnet used for installation of project. Setup creates a setup.exe file.
SetUp : Collecting all the files of a program into a single.exe file.
Deployment : It is a process of installing setup file on the client machine.
Note : The above Setup & Deployment phase process doesn’t include the database. Database setup should be done manually.
No comments:
Post a Comment