8/4/2019 6 Weeks Gagan
http://slidepdf.com/reader/full/6-weeks-gagan 1/51
TABLE OF CONTENTS
Preface
Acknowledgements
Organisational Profile
1 Introduction to C#.NET
2. Introduction to SQL SERVER…………………………………………………
1.1 SQL STATEMENTS
3. ADO.NET ………………………………………………………………….
2.1 Data connection
4. Project description
8/4/2019 6 Weeks Gagan
http://slidepdf.com/reader/full/6-weeks-gagan 2/51
48
MICRO
SOFT
VSUALC#.NE
T|
6/1
9/2009
ACKNOWLEDGEMENT
I take this opportunity to express my deepest gratitude to those who
have generously helped me in providing the valuable
knowledge and expertise during my training. I’m thankful to
Mr. Vikrant Sharma, M.D. of Icon Software Technologies for
his thorough guidance right from day 1st till the end of the
training
Finally, I would like to thank each and every person who
has contributed in any of the ways in our training. I would
also like to thank my college Principal and Training &
Placement Cell Officer for making this six weeks industrial
training a part of B.Tech curriculum.
Last but above all I thank with heart and soul to the
ALMIGHTY who graced me with right thoughts and power
to convert those thoughts into actions.
G AGANDEEP KAUR (CS/07/7130)
8/4/2019 6 Weeks Gagan
http://slidepdf.com/reader/full/6-weeks-gagan 3/51
49
MICRO
SO
FTVSUAL
C#.NE T
|6/1
9/2009
PREFACE
The well planned properly executed and evaluated
training helps a lot in including good culture .It provides
linkage between the student and the institution in order
to develop the awareness of approach to problem solving
based on broad understanding of problem solving basedunderstanding of process and mode of operation of an
organization.
This report serves the purpose of elaborating the analysis
and the implementation phases of the above-mentioned
project .All the features that have been included in the
final implementation have been clearly explained to
make the project easy to understand .It has been takencare that this document elicits the system development
process in a clear and well-documented manner.
In the beginning I have provided an abstract into the
general features of the project. As I have provided an
abstract into general features of the project .As I proceed
I delve into more intricate details regarding the working
of the project.
During my stay here I learned how an actual project
progresses, what sort of problems actually occur during
the development of such projects, how to produce quality
products and so on.
8/4/2019 6 Weeks Gagan
http://slidepdf.com/reader/full/6-weeks-gagan 4/51
48
MICRO
SOFT
VSUALC#.NE
T|
6/1
9/2009
ORGANISATIONAL PROFILE
1.1
T at a Glance
Icon Software Technologies is a leading Software Development organization located in
Ludhiana, India. Their core competency lies in ASP.NET/C#.NET/VB.NET Development, asp,
php, C#, and J2EE Software development. They are delivering full-fledge services of web site
development, web design, software programming, database solution, e-business solutions,
multimedia, custom Internet, web applications development and readymade web site packages
for small sites. Icon Software Technologies gained recognition with high quality web
development projects on the local Indian market as well as outside India. Whether you want an
attractive traditional e-commerce website or an e-business solution to manage your business
online or a cutting edge technology with database site, they provide solution for it. They provide
a customized solution for customers according to their requirements by coding their ideas. They
8/4/2019 6 Weeks Gagan
http://slidepdf.com/reader/full/6-weeks-gagan 5/51
8/4/2019 6 Weeks Gagan
http://slidepdf.com/reader/full/6-weeks-gagan 6/51
48
MICRO
SOFT
VSUALC#.NE
T|
6/1
9/2009
4. E-Commerce .Net e-commerce framework-governance solution-commerce storefronts,
supply chain management system
5. Network Installation
Wi-Fi Service in Labs/Campus connectivity solution, LAN networking solution.
MICROSOFT VSUAL C#.NET
• Microsoft Visual C# .NET is a powerful but simple language.
• C# is a modern, object-oriented and type safe language.
• It was aimed primarily for the developers creating Microsoft .NET applications.
• C# inherits some of its features from C++ and VISUAL BASIC but with some bad points
removed, creating a more logical language.
Here, we will basically learn how to:
Start a Microsoft Visual Studio.NET.
Use the Microsoft Visual Studio.NET programming environment.
Create a C# Console application.
Create a C# Windows Forms application
Beginning programming with Microsoft Visual Studio.NET.
8/4/2019 6 Weeks Gagan
http://slidepdf.com/reader/full/6-weeks-gagan 7/51
49
MICRO
SO
FTVSUAL
C#.NE T
|6/1
9/2009
Visual Studio .NET is a tool-rich programming environment containing all the functionality
you’ll need to create large or small C# projects
Create a Console application using Visual Studio.NET.
In Microsoft windows:
1. Click the START button.
2. Point to all programs.
3.Open the Microsoft Visual Studio.NET 2008.
4. Now Visual Studio .NET starts.
8/4/2019 6 Weeks Gagan
http://slidepdf.com/reader/full/6-weeks-gagan 8/51
48
MICRO
SOFT
VSUALC#.NE
T|
6/1
9/2009
5. FIND menu New Project.
Ctrl+ shift+ N
8/4/2019 6 Weeks Gagan
http://slidepdf.com/reader/full/6-weeks-gagan 9/51
49
MICRO
SO
FTVSUAL
C#.NE T
|6/1
9/2009
This dialog box allows you to create a new project using various templates such asWindows Application, Class Library, and Console Application that specify the type of
application you want to create.
In the Templates pane, click the Console Application icon.
Change the name of the project as TEXTHELLO.
The New Window appears as:
8/4/2019 6 Weeks Gagan
http://slidepdf.com/reader/full/6-weeks-gagan 10/51
48
MICRO
SOFT
VSUALC#.NE
T|
6/1
9/2009
6. For saving your project…FILE menu save TEXTHELLO.(Ctrl+S).
8/4/2019 6 Weeks Gagan
http://slidepdf.com/reader/full/6-weeks-gagan 11/51
49
MICRO
SO
FTVSUAL
C#.NE T
|6/1
9/2009
NOTE: If the folder you specify does not exist, Visual Studio .NET will create it for you.
The menu bar provides access to the commands you’ll use in the programmingenvironment.
The toolbar is located beneath the menu bar and provides button shortcuts to run the
most frequently used commands.
Code pane displays the source files.
In a multifile project, each source file has its own tab labeled with the name of the source
file.
Before writing the code, examine the files listed in the Solution Explorer that Visual Studio.NET has created as part of your project:
TEXTHELLO.sln: Top level solution file of which there is one per application.
TEXTHELLO.csproj: This is a C# project file. Each project file contains one or more
source files. The source files in a single project must be written in the same programminglanguage.
Class1.cs : This is a C# source file. You will write your code in this file.
AssemblyInfo.cs :This is another C# source file. You can use this file to add attributes to
your program, such as the name of the author, the date the program was written, and so
on.
App.ico :This is the icon that is associated with the application.
8/4/2019 6 Weeks Gagan
http://slidepdf.com/reader/full/6-weeks-gagan 12/51
48
MICRO
SOFT
VSUALC#.NE
T|
6/1
9/2009
.NET is a framework. What was its need?
8/4/2019 6 Weeks Gagan
http://slidepdf.com/reader/full/6-weeks-gagan 13/51
49
MICRO
SO
FTVSUAL
C#.NE T
|6/1
9/2009
WRITING OUR FIRST PROGRAM
Class1.cs file defines a class called Class1 that contains a method called Main. All methodsmust be defined inside a class.
1. Why the main method is always “STATIC”?Ans.: The Main method is special— it designates the program’s entry point. It mustBe a static method. Important: C# is a case-sensitive language. You must spell Main with a
capital M.
WRITE THE CODE USING INTELLISENSE TECHNOLOGY
Main should look like this:
Add a blank line after the opening braces and type Console.
NOTE: Console is a built-in-class that contains the methods for displaying th e messages
on the screen and getting the input from the keyboard. Console contains a call to the
WriteLine method.console keyword class used just before the writeline function call
tells the compiler that the WriteLine method is contained in a class called Console.
WriteLine function is a member of the Console class.
2.Type a dot after Console. An IntelliSense list appears. This list contains all the methods, properties and fields of the Console class.
3.Scroll down through the list by pressing the Down Arrow key repeatedly until WriteLine
is selected, and then press Enter. Alternatively, you can use the mouse to scroll through
the list, and then double- click WriteLine.
4.The IntelliSense list closes, and the WriteLine method is added to the source file. Main
should now look like this:
static void Main(string[] args)
{Console.WriteLine
}
5. Type a left parenthesis. An IntelliSense tip appears.
6.This tip displays the parameters of the WriteLine method. In fact, WriteLine is an
overloaded method, meaning that Console contains more than one method named
WriteLine.
8/4/2019 6 Weeks Gagan
http://slidepdf.com/reader/full/6-weeks-gagan 14/51
48
MICRO
SOFT
VSUALC#.NE
T|
6/1
9/2009
7.You can click the tip’s up and down arrows to scroll through the overloaded versions of
WriteLine.
8.Type the right parenthesis, followed by a semicolon (;)
9.Main should now look like this:
static void Main (string[] args)
{
Console.WriteLine ();}Type the string “Hello World” between the left and right parentheses. The text inside the
Write Line () parentheses is a string. A string in C# is a collection of characters enclosed
in double quotes and kept together as a unit.
10. There's a lot of information on line which you can read as follows: "C# compiler, I want
to call the WriteLine() with a string parameter of 'Hello World!' The WriteLine() function
can be found in a class called Console, and the Console class can be found in anamespace called System."
8/4/2019 6 Weeks Gagan
http://slidepdf.com/reader/full/6-weeks-gagan 15/51
49
MICRO
SO
FTVSUAL
C#.NE T
|6/1
9/2009
11. All C# statements must end with a semicolon. The semicolon separates one statement
from another in C#.
BUILDING A CLASS:
A class is a container of all the code that is contained within the application. Unlike in C/C++,
all your code must be contained within a class, with few exceptions. The exceptions to this ruleare:
1. The using statement.
2. Structure declarations.
3. A namespace declaration.
Any attempt to write code that is not contained within a class results in a compiler error.
BUILDING UP MAIN () METHOD:
Every application in c# must a method called “Main ()”. A METHOD IS BASICALLY A SET
OF INSTRUCTIONS THAT CAN PERFORM AN ACTION.THIS METHOD CAN RETURN A INFORMATION TO THE SECTION OF CODE THAT CALLED IT.
Generally the terms “method” and “function” are used interchangeably, but there is some
distinction. Method is function contained within the class but a function is a group of
instructions outside the class generally contained in a language such as C++.
Because you cannot add code outside the class in C# so you can never have a function in C#.
PUBLIC KEYWORD:
It makes the main () method publicly accessible. Not only is the main () method available from
within your application to other methods but also externally from all other applications. By
declaring your Main () method as public, you are creating an entry point for Windows to start the
application when a user wants to run it.
STATIC KEYWORD:
The word “static” in the method declaration means that the compiler should allow only one
copy of the method to exist in memory at a given time.
Because the Main() method is the entry point into your application, it would be
catastrophic(sudden disaster) to allow the entry point to be loaded more than once; this would
generate more than one copy of the application in memory and undoubtedly some severe errors.
VOID KEYWORD: Void is what your main function returns when it has completed running. Void means that your application returns no value after it has completed.
8/4/2019 6 Weeks Gagan
http://slidepdf.com/reader/full/6-weeks-gagan 16/51
48
MICRO
SOFT
VSUALC#.NE
T|
6/1
9/2009
Tip: Get into the habit of typing matched character pairs, such
as (and) and {and}, before filling in their contents. It’s easy to
forget the closing character if you wait until after you’ve
entered the contents.
Build and run your console application
• BUILD menu build solution(F6)
• On the Build menu, click Build Solution. The build succeeds and the following line isdisplayed in the Output pane:
Build: 1 succeeded, 0 failed, 0 skipped
A N ASTERISK AFTER THE FILENAME IN THE C ODE PANE INDICATES THAT THE FILE HAS BEEN CHANGED SINCE IT WAS LAST SAVED . T HERE IS NO NEED TO MANUALLY SAVE THE FILE BEFORE BUILDING BECAUSE THE BUILD
SOLUTION COMMAND SAVES AUTOMATICALLY.
• On the DEBUG menu click Start without Debugging (Ctrl+F5).the program runs in
a command window and writes “HELLO WORLD” as shown in illustration.
8/4/2019 6 Weeks Gagan
http://slidepdf.com/reader/full/6-weeks-gagan 17/51
49
MICRO
SO
FTVSUAL
C#.NE T
|6/1
9/2009
Be sure to click Start Without Debugging and not Start. The Start command runs the program
in a Command shell but does not pause at the end of the run.
• In the Solution Explorer, click Show All Files. Entries named bin and obj appear above
the C# source filenames.
• These correspond directly to folders named bin and obj in the project folder. These
folders are created when you build your application, and they contain the executable
version of the program and other files used for debugging the program.
• In the Solution Explorer, click the + to the left of the bin entry. A nested entry named
Debug appears.
Using Namespaces:
Classes in the .NET Framework are organized into groups called namespaces.A namespace is a logical grouping of classes.
Avoid name clashes between namespaces and types. In other words, don’t create a class with the
same name as a namespace. A namespace can contain multiple classes.
8/4/2019 6 Weeks Gagan
http://slidepdf.com/reader/full/6-weeks-gagan 18/51
48
MICRO
SOFT
VSUALC#.NE
T|
6/1
9/2009
Creating a windows forms application
The Visual Studio .NET programming environment also contains everything you’ll need to
create Windows applications.This means there are two views of the application:
• The Design View.
•The Code View.
The Code pane doubles as the Design View window, and you can switch between the two views
whenever you want.
1. FILE menu new project (Ctrl+shift+N).
2. Choose Windows Form application.
In the following exercise, you’ll use the Visual Designer to add three controls to the Windows
form and examine some of the C# code automatically generated by Visual Studio .NET to
implement these controls.
I. VIEW menu Toolbox (Ctrl+w,X )
TIP: If the Toolbox obscures the form, click the Toolbox’s Auto Hide
button. This moves the form to the foreground.
II. Toolbox----Label and then click on top-left of the form. A LABEL control is added to
the form.
8/4/2019 6 Weeks Gagan
http://slidepdf.com/reader/full/6-weeks-gagan 19/51
49
MICRO
SO
FTVSUAL
C#.NE T
|6/1
9/2009
III. ToolBox----TextBox and then click under the label in the form. A textbox control is
added to the form.
IV. ToolBox----Button and then click to the right of of the TextBox and a button control is
added to the form.
V. Solution Explorer---click View Code.
VI. Form1.cs appears in the code and text editor window.
VII. There are now two tabs named Form1.cs in the Code/Design View window.
VIII. You can click the one suffixed with [Design] to return to Design View at any time.
IX. Form1.cs actually contains the code generated automatically by the visual
studio.net.scroll through the contents and note the following things:
Using directives: visual studio has used a no. of using direstives at the top of thesource file.
8/4/2019 6 Weeks Gagan
http://slidepdf.com/reader/full/6-weeks-gagan 20/51
48
MICRO
SOFT
VSUALC#.NE
T|
6/1
9/2009
Visual studio has used the name of the project file as the name of the top
level namespace.
Visual studio.NET has created the written a class called Form1 inside the
FIRSTWINDOW application.
This class implements the form you created in the Design View
Visual Studio .NET has written a constructor for the Form1 class as:
public partial class Form1 : Form
{ public Form1() //constructor
{ InitializeComponent();}
}
• Visual Studio .NET has written a method of the Form1 class called Initialize
Component. This method is hidden in a collapsed region named Windows FormDesigner Generated Code. Click the + to the left of this label to expand the region.
• The statements inside this method set the properties of the controls you added to the form
in the design view.
Never modify the contents of the Initialize Component method with the Code And
Text Editor window. If you make changes to the properties of
components in Design View or in the Properties window, your code
modifications will be lost.
• Main is the program entry point it creates an instance of form1 and runs it.
1) Solution explorer-----view designer. Designer window opens.
2) View---properties window (Ctrl+ W, P)
3) Select the button of the form and the properties window displays the selected button’s
properties.
4) Properties window----text property----highlight the text.
8/4/2019 6 Weeks Gagan
http://slidepdf.com/reader/full/6-weeks-gagan 21/51
49
MICRO
SO
FTVSUAL
C#.NE T
|6/1
9/2009
5)Type OK and then press ENTER. On the form, the button’s text changes to OK.
6) The label is selected and the Properties window displays the selected label’s properties.
7) Properties window----text property----highlight the text.
8)Type ENTER YOUR NAME and then press ENTER.
9) The TEXTBOX is selected and the Properties window displays the selected textbox’s
properties.
10) Properties window----text property----highlight the text.
11) Type HERE and then press ENTER.
HOW TO ADD CODE THAT RUNS WHEN THE OK BUTTON IS CLICKED?
12) Move the mouse pointer over the OK button and then double-click it.
13) Form1.cs source file appears in the Code window. Visual Studio .NET has added
a method called button1_Click to the Form1 class. It has also added a statement to the
Initialize Component method to automatically call button1_Click when the OK button isclicked.
14) Type the following Message Box statement inside the button1_Click method:
private void button1_Click(object sender, EventArgs e)
{
MessageBox.Show("HELLO "+textBox1.Text);}
15) DEBUG menu----start without debugging(Ctrl + F5).
16) Enter your name, and then click OK. A message appears welcoming you by name.
17) Click OK and the message closes.
8/4/2019 6 Weeks Gagan
http://slidepdf.com/reader/full/6-weeks-gagan 22/51
48
MICRO
SOFT
VSUALC#.NE
T|
6/1
9/2009
8/4/2019 6 Weeks Gagan
http://slidepdf.com/reader/full/6-weeks-gagan 23/51
49
MICRO
SO
FTVSUAL
C#.NE T
|6/1
9/2009
WORKING WITH VARIABLES, OPERATORS AND
EXPRESSIONS. In this section, we will learn elements of Visual C# syntax and semantics.
UNDERSTANDING STATEMENTS:
A statement is a command that performs an action. Statements are found inside methods (a
method as a named sequence of statements inside a class).
Statements in C# must follow a well-defined set of rules. These rules are collectively known as
syntax.
The specification of what statements do is collectively known as semantics.
TIP: C# is a “free format” language, which means that white space, such as a space character
or a new line, is not significant except as a separator .
USING IDENTIFIERS:
These are the names we use to identify the elements in our program.
C# is case sensitive language.
Rules or syntax to give identifiers are as follows:
1. You can use only letters (uppercase and lowercase), digits, and underscore characters.
2. An identifier must start with a letter (an underscore is considered a letter).
USING KEYWORDS:
The C# language reserves 76 identifiers for its own use. These identifiers are called keywords.
Each has a particular meaning.
USING VARIABLES:
A variable is a storage location that holds a value. Box holding temporary information.1. Don’t use underscores.
2.Don’t create identifiers that differ only by case. For example, do not create one variable
named myVariable and another named MyVariable for use at the same time.3. Start the name with a lowercase letter.
4. In a multiword identifier, start the second and each subsequent word with an uppercase
letter. This is known as camelCase notation. DECLARING VARIABLES:
C# has many different type of values it can process.
• Integers.
• Floating-point numbers.
• Strings.
When you declare a variable, you must specify what kind of data it will hold.the information
to be included in the declaration statement is the type and the name of the variable.
An assignment operator ‘=’ assigns a particular value to the variable being declared.
8/4/2019 6 Weeks Gagan
http://slidepdf.com/reader/full/6-weeks-gagan 24/51
48
MICRO
SOFT
VSUALC#.NE
T|
6/1
9/2009
WORKING WITH BUILT-IN DATA TYPES:
Data type Description Size (bits) Range* Sample usage
Int, Whole numbers
Data type Description Size (bits) Range* Sample usage
Int Whole numbers 32 -231 through231-1.
int count;count= 42;
Long Whole numbers(bigger range)
64 -263 through263-1.
long wait;wait =42L
float Floating-point
numbers
32 ±3.4 × 1038 float away;
away =0.42F;
PRECEDENCE:
Precedence is the order in which an expression’s operators are evaluated.
ASSOCIATIVITY:
Associativity is the direction (left or right) to which an expression’s operators are bound.
INCREMENTING AND DECREMNETING VARIABLES:
count++; // postfix increment
++count; // prefix increment
count--; // postfix decrement--count; // prefix decrement
ITERATION STATEMENTS
If statement:
The if statement is used when we want to execute more than one statement.The syntax of an if statement is as follows:(if &else are keywords)
if ( booleanExpression )
statement-1
elsestatement-2
If booleanExpression evaluates to true, then statement-1 runs; otherwise, the booleanExpression
is false and statement-2 runs. The expression in an if statement must be enclosed in parentheses.
Additionally, the expression must be a Boolean expression.C and C++ allow to write an integer expression and silently convert the integer value to true (nonzero) or false (zero) but c# never
does this silent conversion.A block is simply a sequence of statements grouped between a left and a right brace.
You can nest if statements inside other if statements. In this way, you can chain together a
sequence of Boolean expressions.
Switch statement:
8/4/2019 6 Weeks Gagan
http://slidepdf.com/reader/full/6-weeks-gagan 25/51
49
MICRO
SO
FTVSUAL
C#.NE T
|6/1
9/2009
The switch statement evaluates an expression and compares the expression's value to a variety of
cases. Each case is associated with a statement list, called a switch section. C# executes the
statement list associated with the switch section matching the expression's value.The expression used as the driver for the switch statement is enclosed in parentheses.
Syntax:switch ( controllingExpression )
{case constantExpression :
statements
break;case constantExpression :
statements
break;
?default :
statements
break;
}• You can use switch only on primitive data types (such as int) and string. If you need to
use switch on any other types, you’ll have to use an if statement.
• Your case labels must be constant expressions, such as 42 or “42”.
The default statement list executes when none of the other switch sections define constants that
match the switch expression. The default statement list is the catchall that says, "If you can't find
a matching switch block, execute this default code." Using the default keyword is optional in
your switch statements.
Iteration statements to execute EMBEDDED SYSTEMS.
The expression associated with the iteration statements controls the number of times that an embedded statement multiple lines executes.
While statement:
The while statement executes an embedded statement list as long as the while
expression evaluates to true. The Boolean expression that controls the while
statement is enclosed in parentheses that follow the while keyword.
The while statement executes its embedded statements zero or more times.
Do statement :
8/4/2019 6 Weeks Gagan
http://slidepdf.com/reader/full/6-weeks-gagan 26/51
48
MICRO
SOFT
VSUALC#.NE
T|
6/1
9/2009
If you want to ensure that the embedded statements are executed at least once, you can use a do
statement.
Commenting Your Code
Commenting your code lets you add notes to your C# source files. These notes can help you
document the design and flow of your application. Comments can appear anywhere in your C#source code where whitespace is legal.
Using one-line comments
One-line comments begin with two slashes and remain in effect for the rest of the line:{// this is an opening brace
System.Console.WriteLine ("C#"); // call WriteLine ()
} // this is a closing brace
Using regular comments
Regular comments begin with a slash followed by an asterisk and remain in effect until anasterisk followed by a slash is found. Regular comments can span multiple lines:
/*This is a regular comment in C#.
It contains multiple lines of text,
Separated by NewLine characters.
WRITING METHODS AND APPLYING SCOPE.
• DECLARING METHODS
A method is named sequence of statements. Each method has a name and a body.
A function defined within a class is called method. It is a code designed to work on the
member data of class.
The method body contains the actual statements to be run when a method is being called.
The method name should be a meaningful identifier which defines the purpose of the
method.
• METHOD DECLARATION SYNTAX:
THE SYNTAX OF THE MICROSOFT VISUAL C# METHOSD IS:
returnType methodName(parameter list)
{
\\method body containing statements;
return(value);
8/4/2019 6 Weeks Gagan
http://slidepdf.com/reader/full/6-weeks-gagan 27/51
49
MICRO
SO
FTVSUAL
C#.NE T
|6/1
9/2009
}
The returnType is the name of a type and specifies what kind of information the
method returns.
The methodName is the name used to call a method.
The parameter list is optional and describes the type and the name of the information
a method accepts. You write the parameters between the left and right parentheses asthough you’re declaring variables: name of the type, followed by the name of the
parameter. If the method you’re writing has two or more parameters, you must separate
them with commas.
.
The method body statements are the lines of code that the method runs when it is being
called enclosed in curly braces.
TIP: C# does not support global methods. You must write all your methods inside a class or
your code will not compile.
• WRITING RETURN STATEMENTS:
If we want our method to return some info we do this by using return keyword followed
by an expression that calculates the returned value followed by a semicolon.
The return statement should be at the end of your method because it causes the method to
finish. Any statements after the return statement will not be executed.
If you want to get exit from your method you can use return followed by a semicolon.
Return;
CALLING METHOD SYNTAX:
methodName (argument list)
The methodName should match exactly the name you are calling.
The argumentList supplies the optional information that the method accepts. Argument is
the data passed from a program to a function.
A variable can be created inside a method but can be used only at certain places after it has
been created. That is, it can only be used inside the method in which it is defined and
disappears as soon as the method is finished.
CREATING LOCAL SCOPE INSIDE A METHOD:
Any variables you declare inside the body of a method are scoped to that method. These
variables are called local variables because they are local to the method in which they aredeclared; they are not in scope in any other method.
8/4/2019 6 Weeks Gagan
http://slidepdf.com/reader/full/6-weeks-gagan 28/51
48
MICRO
SOFT
VSUALC#.NE
T|
6/1
9/2009
CREATING CLASS SCOPE WITH A CLASS:
The left and right curly braces that form the body of a class also create a scope. Any “variables”you declare inside the body of a class (but not inside a method) are scoped to that class. The
proper C# name for these variables is fields. In contrast to local variables, you can use fields to
share information between methods.
In a method, you must declare a variable before you can use it. Fields are a little different. A
method can use a field before the field is defined—the compiler sorts out the details for you!
OVERLOADING METHODS
Overloading refers to the use of the same thing for different purposes. Method
overloading means the use of same method name to create methods that
perform a variety of different tasks. But the rules to distinguish between
them are to use different no. and type of argument list. A method calls
first matches the prototype having the same number and type of arguments and then calls the appropriate method for execution.
8/4/2019 6 Weeks Gagan
http://slidepdf.com/reader/full/6-weeks-gagan 29/51
49
MICRO
SO
FTVSUAL
C#.NE T
|6/1
9/2009
Introduction to SQL
Microsoft SQL Server 2000 is a full-featured relational database management system
(RDBMS) that offers a variety of administrative tools to ease the burdens of database
development, maintenance and administration.
The history of SQL begins in an IBM laboratory in San Jose, California, where SQL was
developed in the late 1970s. The initials stand for Structured Query Language, and the
language itself is often referred to as "sequel." It was originally developed for IBM's DB2
product (a relational database management system, or RDBMS.
Enterprise Manager :is the main administrative console for SQL Server installations. It
provides you with a graphical "birds-eye" view of all of the SQL Server installations on your
network. You can perform high-level administrative functions that affect one or more servers,schedule common maintenance tasks or create and modify the structure of individual databases.
Query Analyzer offers a quick and dirty method for performing queries against any of your SQL Server databases. It's a great way to quickly pull information out of a database in response
to a user request, test queries before implementing them in other applications, create/modify
stored procedures and execute administrative tasks.
SQL Profiler provides a window into the inner workings of your database.
Service Manager is used to control the MSSQLServer (the main SQL Server process), MSDTC
(Microsoft Distributed Transaction Coordinator) and SQLServerAgent processes. An icon for this service normally resides in the system tray of machines running SQL Server. You can useService Manager to start, stop or pause any one of these services.
Data Transformation Services (DTS) provide an extremely flexible method for importing and
exporting data between a Microsoft SQL Server installation and a large variety of other formats.
Editions of sql server:
• SQL Server Compact Edition (SQL CE)
• SQL Server Developer Edition
• SQL Server 2005 Embedded Edition (SSEE)
• SQL Server Enterprise Edition
• SQL Server Evaluation Edition
• SQL Server Express Edition
• SQL Server Fast Track
• SQL Server Standard Edition
8/4/2019 6 Weeks Gagan
http://slidepdf.com/reader/full/6-weeks-gagan 30/51
48
MICRO
SOFT
VSUALC#.NE
T|
6/1
9/2009
• SQL Server Web Edition
• SQL Server Workgroup Edition
The SQL Server Full Text Search service architecture
Database Tables
A database is primarily a group of computer files that each has a name and a location.
A database most often contains one or more tables. Each table is identified by a name (e.g.
"Customers").Tables contain records (rows) with data. Below is an example of a table called“person”.
P_ID LAST NAME FIRST NAME ADDRESS CITY
1 GREWAL GAGAN SAHNEWAL LUDHIANA
2 KOHLI RABIA SECTOR-34 CHANDIGARH3 BAINS DEEPINDER NURPUR ROPAR
4 GILL PREETI SECTOR-10 CHANDIGARH
The table “person” contains:
• 3 records (rows).
• 5 columns
SQL Statements:
SQL Statements:
1.SELECT Statement :
# SELECT column-name FROM table-name;
8/4/2019 6 Weeks Gagan
http://slidepdf.com/reader/full/6-weeks-gagan 31/51
49
MICRO
SO
FTVSUAL
C#.NE T
|6/1
9/2009
SELECT statements do not modify data in any way. They are simply a method of looking
at the data stored in a single table or in many related tables. SELECT statements do not
generate a transaction in Microsoft SQL Server either.
There are three keywords to keep in mind when retrieving data through SQL: SELECT,
FROM, and WHERE.
The SELECT list is the list of columns that you wish to return from the query. Dependingon your query, these columns can be from one table or multiple tables. You can return allof the column values or manipulate the column to return a computed value, or you can
combine column values to create something totally new. The FROM statement specifies
the table, tables, or views from which you want to retrieve the data. The WHERE clause
specifies which rows to include or exclude for your query’s output.
Omitting the WHERE clause will return or manipulate all rows in the table.
SELECT statement syntax
SELECT [ALL | DISTINCT] select_list
[INTO [new_table_name]][FROM {table_name | view_name}[(optimizer_hints)]
[[, {table_name2 | view_name2}[(optimizer_hints)]
[…, {table_name16 | view_name16}[(optimizer_hints)]]]
[WHERE clause]
[GROUP BY clause]
[HAVING clause]
[ORDER BY clause]
[COMPUTE clause]
[FOR BROWSE]
Most of the actions you need to perform on a database are done with SQL statements.
The following SQL statement will select all the records in the "Person" table:
SELECT * FROM person;
NOTE: SQL is not case-sensitive.* is a quick way of selecting allthe columns in table.
Semicolon after SQL Statements?
Some database systems require a semicolon at the end of each SQL statement.
Semicolon is the standard way to separate each SQL statement in database systems that allow
more than one SQL statement to be executed in the same call to the server.
For using MS Access and SQL Server 2000 and we do not have to put a semicolon after eachSQL statement, but some database programs force you to use it.
8/4/2019 6 Weeks Gagan
http://slidepdf.com/reader/full/6-weeks-gagan 32/51
48
MICRO
SOFT
VSUALC#.NE
T|
6/1
9/2009
SQL DML and DDL
SQL can be divided into two parts: The Data Manipulation Language (DML) and the Data
Definition Language (DDL).
The query and update commands form the DML part of SQL:
• SELECT - extracts data from a database
• UPDATE - updates data in a database
• DELETE - deletes data from a database
• INSERT INTO - inserts new data into a database
The DDL part of SQL permits database tables to be created or deleted. It also define indexes
(keys), specify links between tables, and impose constraints between tables. The most important
DDL statements in SQL are:
• CREATE DATABASE - creates a new database• ALTER DATABASE - modifies a database
• CREATE TABLE - creates a new table
• ALTER TABLE - modifies a table
• DROP TABLE - deletes a table
• CREATE INDEX - creates an index (search key)
• DROP INDEX - deletes an index.
Navigation in a Result-set
Most database software systems allow navigation in the result-set with programming functions,
like: Move-To-First-Record, Get-Record-Content, Move-To-Next-Record, etc.
SQL SELECT DISTINCT Statement :
In a table, some of the columns may contain duplicate values. This is not a problem, however,
sometimes you will want to list only the different (distinct) values in a table. The DISTINCT
keyword can be used to return only distinct (different) values.
# SELECT DISTINCT column-name FROM table-name;
SQL WHERE Clause:The WHERE Clause is used to extract only those records that fulfill a specified criterion.
# SELECT column-name FROM table-name WHERE column-name operator-value;
Quotes around Text Fields
8/4/2019 6 Weeks Gagan
http://slidepdf.com/reader/full/6-weeks-gagan 33/51
49
MICRO
SO
FTVSUAL
C#.NE T
|6/1
9/2009
SQL uses single quotes around text values (most database systems will also accept double
quotes).Although, numeric values should not be enclosed in quotes.
Operators Allowed in the WHERE Clause:
OPERATOR DESCRIPTION= equal to
<> not equal to
> Greater than
< Less than
>= Greater than or equal
<= Less than or equal
BETWEEN Between an inclusive range
LIKE Search for a pattern
IN If you know the exact value you want to return
for at least one of the columns
2.SQL AND & OR Operators:
It is used to filter records based on one or more condition. The AND operator displays a record if
both the first condition and the second condition is true.
The OR operator displays a record if either the first condition or the second condition is true.
# SELECT * FROM table-name WHERE coulmn-name1=’ ’ AND coulmn-name2=’ ’;
SQL ORDER BY Keyword:It is used to sort the result-set by a specified-column in ascending order by default and you can
use DESC keyword for descending order.
# SELECT column-name FROM table-name ORDER BY column-name ASC|DESC.
SQL INSERT INTO Statement : The INSERT INTO statement is used to insert a new row in a table.The first form doesn't specify
the column names where the data will be inserted, only their values:
# INSERT INTO table-name VALUES (value1, value2……);
8/4/2019 6 Weeks Gagan
http://slidepdf.com/reader/full/6-weeks-gagan 34/51
48
MICRO
SOFT
VSUALC#.NE
T|
6/1
9/2009
Insert Data Only in Specified Columns:
It is also possible to only add data in specific columns.
# INSERT INTO table-name (column 1, column 2) VALUES (value1, value2….);
SQL UPDATE Statement: The UPDATE statement is used to update existing records in a table.
# UPDATE table_name SET column1=value, column2=value2….WHERE
some_column=some_value
SQL DELETE Statement:
It is used to delete records(rows) from the table.
# DELETE FROM table-name WHERE some-column=some-value;
Delete All Rows
It is possible to delete all rows in a table without deleting the table. This means that the table
structure, attributes, and indexes will be intact:
# DELETE FROM table-name.
OR
# DELETE * FROM table-name.
SQL TOP Clause:
The TOP clause is used to specify the number of records to return.The TOP clause can be veryuseful on large tables with thousands of records. Returning a large number of records can impact
on performance.
# SELECT TOP column|percent column-name FROM table-name
SQL LIKE Operator:The LIKE operator is used in a WHERE clause to search for a specified pattern in a column.
# SELECT column-name FROM table-name column-name LIKE pattern (‘a%’)
8/4/2019 6 Weeks Gagan
http://slidepdf.com/reader/full/6-weeks-gagan 35/51
49
MICRO
SO
FTVSUAL
C#.NE T
|6/1
9/2009
The "%" sign can be used to define wildcards (missing letters in the pattern) both before and
after the pattern. NOT keyword can also be used in it.
SQL Wildcards:
It can be used while searching for data in a database. SQL wildcards can substitute for one or more characters when searching for data in a database.SQL wildcards must be used with the SQL LIKE operator. With SQL the following wildcards
can be used:
Wildcard Description
% A substitute for zero or more characters.
_ A substitute for exactly one character
[charlist] Any single character in charlist.
[^charlist] Any single character not in list.
Using the _ Wildcard
Now we want to select the persons with a first name that starts with any character, followed by
"la" from the "Persons" table.
# SELECT column-name FROM table-name column-name LIKE ‘_la’;
Using the [charlist] Wildcard
Now we want to select the persons with a last name that starts with "b" or "s" or "p" from the
"Persons" table.
# SELECT column-name FROM table-name column-name LIKE [bsp%];
Next, we want to select the persons with a last name that do not start with "b" or "s" or "p" from
the "Persons" table.
# SELECT column-name FROM table-name column-name LIKE [!bsp%];
Tip:! Stands for not equal to.
SQL IN OperatorIt allows you to specify multiple values in a WHERE clause.
8/4/2019 6 Weeks Gagan
http://slidepdf.com/reader/full/6-weeks-gagan 36/51
48
MICRO
SOFT
VSUALC#.NE
T|
6/1
9/2009
# SELECT column-name FROM table-name WHERE column-name IN (value1, value2...)
SQL BETWEEN Operator:The BETWEEN operator is used in a WHERE clause to select a range of data between two
values. The values can be numbers, text, or dates.
# SELECT column-name FROM table-name WHERE column-name BETWEEN value1 AND
value2.
Note: The BETWEEN operator is treated differently in different databases.
In some databases the BETWEEN operator only selects fields that are between and excluding the
test values.
In other databases, persons the BETWEEN operator selects fields that are between and includingthe test values.
And in other databases the BETWEEN operator selects fields between the test values, includingthe first test value and excluding the last test value.
• To display the persons outside the range in the previous example, use NOT BETWEEN.
SQL Alias: With SQL, an alias name can be given to a table or to a column. This can be a good thing
to do if you have very long or complex table names or column names. An alias name isusually short.
SQL Alias Syntax for Tables
# SELECT column-name FROM table-name AS alias-name;
SQL Alias Syntax for columns
# SELECT column-name AS alias-name FROM table-name;
SQL Joins: It is used to query data from 2 or more tables based on a relationship between certain
columns in these tables. Tables in database are often related to each other with keys.
A primary key is a column (or a combination of columns) with a unique value for each
row. Each primary key value must be unique within the table. The purpose is to bind data
together, across tables, without repeating all of the data in every table.
8/4/2019 6 Weeks Gagan
http://slidepdf.com/reader/full/6-weeks-gagan 37/51
49
MICRO
SO
FTVSUAL
C#.NE T
|6/1
9/2009
Different SQL JOINs
Before we continue with examples, we will list the types of JOIN you can use, and the
differences between them.
• JOIN: Return rows when there is at least one match in both tables• LEFT JOIN: Return all rows from the left table, even if there are no matches in the right
table
• RIGHT JOIN: Return all rows from the right table, even if there are no matches in the lefttable
• FULL JOIN: Return rows when there is a match in one of the tables.
ADO.NET
INTRODUCTION
8/4/2019 6 Weeks Gagan
http://slidepdf.com/reader/full/6-weeks-gagan 38/51
48
MICRO
SOFT
VSUALC#.NE
T|
6/1
9/2009
It is the new database technology used in .NET platform.
It covers the classes in the System.data namespace. It is
a set of classes that expose the data access services of
the .NET framework. The .NET framework divides ADO.NET functionality into
logical namespaces.ADO.NET is implemented primarily in
the System.data namespace hierarchy which physically
resides in the System.data.Dll assembly. some parts of
ADO.NET are part of System.XML namespace.
NAMESPACE DESCRIPTION
System.data Core of the ADO.NET.
Includes classes that make
up the disconnected part of
the ADO.NET architecture.
System.data.Common Includes classes and
interfaces that are inherited
and implemented by .NETproviders.
System.data.SqlClient Sql Server .NET data
provider.
System.data.OleDb OLE DB .NET data provider
System.data.Oracle ORACLE .NET data provider.
System.data.ODBC ODBC .NET data provider.System.data.SqlTypes Classes and structures for
native Sql server data
types.
8/4/2019 6 Weeks Gagan
http://slidepdf.com/reader/full/6-weeks-gagan 39/51
49
MICRO
SO
FTVSUAL
C#.NE T
|6/1
9/2009
VENDOR HELP DESK
Project Description:
VHD is an active helpdesk and a single windowsolution for enhancing vendors satisfaction level andprovides hassle-free service to various departmentsand vendors.
VHD provides a techno-driven approach inmonitoring and maintaining the records of purchaseorders, invoices and payments.
Assist in prompt resolution of vendor queriesregarding status of their purchase orders, invoicesand payments.
Moves invoices within the departments specificallyand tracks their movements efficiently.
Escalate vendor payments and inform the vendorsvia mail/phone about their payments.
Always stay in touch and keeps reporting to variousdepartments about the status of purchase orders,invoices and their movement and payments on dailybasis.
Scope of Work:
Receiving & recording Purchase Orders, Capex, Opexon daily basis.
Receiving & recording Bills submitted by vendors.
8/4/2019 6 Weeks Gagan
http://slidepdf.com/reader/full/6-weeks-gagan 40/51
48
MICRO
SOFT
VSUALC#.NE
T|
6/1
9/2009
Forwarding bills to users after allotting controlnumber and receiving back.
Query resolution with vendor & resubmission of billto the user.
Approved bill forwarded to Finance for payment.
Query resolution of Finance through user.
Dispatch of Cheques to vendors.
Inform updating status of pending invoices andpayments to vendors via mail/phone.
8/4/2019 6 Weeks Gagan
http://slidepdf.com/reader/full/6-weeks-gagan 41/51
49
MICRO
SO
FTVSUAL
C#.NE T
|6/1
9/2009
LOGIN FORM
8/4/2019 6 Weeks Gagan
http://slidepdf.com/reader/full/6-weeks-gagan 42/51
48
MICRO
SOFT
VSUALC#.NE
T|
6/1
9/2009
MASTER DEPARTMENT FORM
8/4/2019 6 Weeks Gagan
http://slidepdf.com/reader/full/6-weeks-gagan 43/51
49
MICRO
SO
FTVSUAL
C#.NE T
|6/1
9/2009
MASTER VENDOR FORM
8/4/2019 6 Weeks Gagan
http://slidepdf.com/reader/full/6-weeks-gagan 44/51
48
MICRO
SOFT
VSUALC#.NE
T|
6/1
9/2009
BILL MOVEMENT FORM
8/4/2019 6 Weeks Gagan
http://slidepdf.com/reader/full/6-weeks-gagan 45/51
49
MICRO
SO
FTVSUAL
C#.NE T
|6/1
9/2009
BILL ORDERS
8/4/2019 6 Weeks Gagan
http://slidepdf.com/reader/full/6-weeks-gagan 46/51
48
MICRO
SOFT
VSUALC#.NE
T|
6/1
9/2009
SALES DEPARTMENTFORM
8/4/2019 6 Weeks Gagan
http://slidepdf.com/reader/full/6-weeks-gagan 47/51
49
MICRO
SO
FTVSUAL
C#.NE T
|6/1
9/2009
FINANCE DEPARTMENT FORM
8/4/2019 6 Weeks Gagan
http://slidepdf.com/reader/full/6-weeks-gagan 48/51
48
MICRO
SOFT
VSUALC#.NE
T|
6/1
9/2009
VENDOR QUERY RESOLUTION
8/4/2019 6 Weeks Gagan
http://slidepdf.com/reader/full/6-weeks-gagan 49/51
49
MICRO
SO
FTVSUAL
C#.NE T
|6/1
9/2009
SCIENTIFIC AND STANDARD CALCULATOR
8/4/2019 6 Weeks Gagan
http://slidepdf.com/reader/full/6-weeks-gagan 50/51
48
MICRO
SOFT
VSUALC#.NE
T|
6/1
9/2009
VENDOR’S REPORT
8/4/2019 6 Weeks Gagan
http://slidepdf.com/reader/full/6-weeks-gagan 51/51
ICRO
SO
FTVSUAL
C#.NE T
|6/1
9/2009
VENDOR HELP DESK BILL RECORDS