Вы находитесь на странице: 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

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. Im 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

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.

GAGANDEEP KAUR (CS/07/7130)

48

MICROSOFT VSUAL C#.NET | 6/19/2009

has contributed in any of the ways in our training. I would

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 based understanding 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 taken care 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.

49

MICROSOFT VSUAL C#.NET | 6/19/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

48

MICROSOFT VSUAL C#.NET | 6/19/2009

see it as an important part of their service to understand customers requirements and proactively meet their needs.

1.2

IST at a Glance

Icon Software Technologies gained recognition with high quality web development projects on the local Indian market as well as outside India. They are website designers & web developers and were recognized as the leading Indian IT related solution & service Provider Company in the area of web designing and web application development, multimedia development & data processing. They provide a comprehensive range of web services including offshore website development, Live Project Training, Onsite Training, multimedia, web applications, web

MICROSOFT VSUAL C#.NET | 6/19/2009

designing and e-commerce & e-business development. They have extensive command on .NET Technology and we are working on its all modules like VB.NET, C#.NET, ASP.NET etc. 1. Website Design & Development Flash Animated Websites, Web site design & Maintenance, Dynamic development, Domain Registration and Hosting. 2. Web Software Development Customized Software Design in ASP.NET MVC/ 3.5 / 2.0/ 1.1 /VB.NET/ C#.NET/XML/ CRYSTAL REPORTS.NET/ MSSQL 3. On Site .NET Training ASP.NET/C#.NET/VB.NET training to your company or institution by our IT professionals to enhance your IT Skills. website

49

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.

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.

48

MICROSOFT VSUAL C#.NET | 6/19/2009

C# is a modern, object-oriented and type safe language.

Visual Studio .NET is a tool-rich programming environment containing all the functionality youll 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.

MICROSOFT VSUAL C#.NET | 6/19/2009


49

3. Open the Microsoft Visual Studio.NET 2008.


4. Now Visual Studio .NET starts.

5. FIND menu Ctrl+ shift+ N

New Project.

48

MICROSOFT VSUAL C#.NET | 6/19/2009

MICROSOFT VSUAL C#.NET | 6/19/2009

This dialog box allows you to create a new project using various templates such as Windows 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:

49

6. For saving your projectFILE menu save TEXTHELLO.(Ctrl+S).

48

MICROSOFT VSUAL C#.NET | 6/19/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 youll use in the programming environment. 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:

MICROSOFT VSUAL C#.NET | 6/19/2009

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 programming language. 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.

49

.NET is a framework. What was its need?

48

MICROSOFT VSUAL C#.NET | 6/19/2009

WRITING OUR FIRST PROGRAM


Class1.cs file defines a class called Class1 that contains a method called Main. All methods must be defined inside a class. 1. Why the main method is always STATIC? Ans.: The Main method is special it designates the programs entry point. It must Be 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.

MICROSOFT VSUAL C#.NET | 6/19/2009

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.

49

7. You can click the tips 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 a namespace called System."

48

MICROSOFT VSUAL C#.NET | 6/19/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 rule are: 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.

MICROSOFT VSUAL C#.NET | 6/19/2009


49

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.

Tip: Get into the habit of typing matched character pairs, such as (and) and {and}, before filling in their contents. Its easy to forget the closing character if you wait until after youve 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 is displayed in the Output pane: Build: 1 succeeded, 0 failed, 0 skipped

AN ASTERISK AFTER THE FILENAME IN THE CODE PANE INDICATES THAT THE FILE HAS BEEN CHANGED SINCE IT WAS LAST SAVED. THERE 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.

48

MICROSOFT VSUAL C#.NET | 6/19/2009

MICROSOFT VSUAL C#.NET | 6/19/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, dont create a class with the same name as a namespace. A namespace can contain multiple classes.

49

Creating a windows forms application The Visual Studio .NET programming environment also contains everything youll 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, youll 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 Toolboxs 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.

48

MICROSOFT VSUAL C#.NET | 6/19/2009

MICROSOFT VSUAL C#.NET | 6/19/2009

III. IV. V. VI.

ToolBox----TextBox and then click under the label in the form. A textbox control is added to the form. ToolBox----Button and then click to the right of of the TextBox and a button control is added to the form. Solution Explorer---click View Code. Form1.cs appears in the code and text editor window. There are now two tabs named Form1.cs in the Code/Design View window. You can click the one suffixed with [Design] to return to Design View at any time. 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 the source file.

VII.
VIII. IX.

49

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 Form Designer 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 buttons properties. 4) Properties window----text property----highlight the text.

48

MICROSOFT VSUAL C#.NET | 6/19/2009

5) Type OK and then press ENTER. On the form, the buttons text changes to OK.
6) The label is selected and the Properties window displays the selected labels 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 textboxs properties.

10) 11)

Properties window----text property----highlight the text. Type HERE and then press ENTER.

MICROSOFT VSUAL C#.NET | 6/19/2009

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 is clicked. 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.

49

48

MICROSOFT VSUAL C#.NET | 6/19/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. Dont use underscores. 2. Dont 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.

MICROSOFT VSUAL C#.NET | 6/19/2009

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.

Integers. Floating-point numbers.

49

WORKING WITH BUILT-IN DATA TYPES: Data type Description Size (bits) Range* Sample usage Int, Whole numbers Data type Description Size (bits) Range* Int Long float Whole numbers Whole numbers (bigger range) Floating-point numbers 32 64 32 -231 through 231-1. -263 through 263-1. 3.4 1038

Sample usage int count; count= 42; long wait; wait =42L float away; away =0.42F;

PRECEDENCE: Precedence is the order in which an expressions operators are evaluated. ASSOCIATIVITY: Associativity is the direction (left or right) to which an expressions 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 else statement-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:

48

MICROSOFT VSUAL C#.NET | 6/19/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; }

MICROSOFT VSUAL C#.NET | 6/19/2009


49

You can use switch only on primitive data types (such as int) and string. If you need to use switch on any other types, youll 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 :

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 an asterisk 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);

48

MICROSOFT VSUAL C#.NET | 6/19/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 as though youre declaring variables: name of the type, followed by the name of the parameter. If the method youre 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.

MICROSOFT VSUAL C#.NET | 6/19/2009

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 are declared; they are not in scope in any other method.

49

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 definedthe 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.

48

MICROSOFT VSUAL C#.NET | 6/19/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.

MICROSOFT VSUAL C#.NET | 6/19/2009

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 use Service 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)

49

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

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 1 2 3 4 LAST NAME GREWAL KOHLI BAINS GILL FIRST NAME GAGAN RABIA DEEPINDER PREETI ADDRESS SAHNEWAL SECTOR-34 NURPUR SECTOR-10 CITY LUDHIANA CHANDIGARH ROPAR CHANDIGARH

The table person contains: 3 records (rows). 5 columns

SQL Statements: SQL Statements:


1.SELECT Statement:
# SELECT column-name FROM table-name;

48

MICROSOFT VSUAL C#.NET | 6/19/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. Depending on your query, these columns can be from one table or multiple tables. You can return all of 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 querys output. Omitting the WHERE clause will return or manipulate all rows in the table. SELECT statement syntax

MICROSOFT VSUAL C#.NET | 6/19/2009


49

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 all the 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 each SQL statement, but some database programs force you to use it.

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:

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

48

MICROSOFT VSUAL C#.NET | 6/19/2009

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.

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 = <> > < >= <= BETWEEN LIKE IN DESCRIPTION equal to not equal to Greater than Less than Greater than or equal Less than or equal Between an inclusive range Search for a pattern If you know the exact value you want to return for at least one of the columns

MICROSOFT VSUAL C#.NET | 6/19/2009

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);

49

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;

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 very useful 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%)

48

MICROSOFT VSUAL C#.NET | 6/19/2009

Delete All Rows

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 % _ [charlist] [^charlist] A substitute for zero or more characters. A substitute for exactly one character Any single character in charlist. Any single character not in list.

MICROSOFT VSUAL C#.NET | 6/19/2009


49

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 Operator
It allows you to specify multiple values in a WHERE clause.

# 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 including the test values. And in other databases the BETWEEN operator selects fields between the test values, including the first test value and excluding the last test value.

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 is usually 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.

48

MICROSOFT VSUAL C#.NET | 6/19/2009

To display the persons outside the range in the previous example, use NOT BETWEEN.

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 left table FULL JOIN: Return rows when there is a match in one of the tables.

MICROSOFT VSUAL C#.NET | 6/19/2009

ADO.NET
INTRODUCTION

49

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 System.data DESCRIPTION Core of the ADO.NET. Includes classes that make up the disconnected part of the ADO.NET architecture. Includes classes and interfaces that are inherited and implemented by .NET providers. Sql Server .NET data provider. OLE DB .NET data provider ORACLE .NET data provider. ODBC .NET data provider. Classes and structures for native Sql server data types.

System.data.Common

System.data.SqlClient System.data.OleDb System.data.Oracle System.data.ODBC System.data.SqlTypes

48

MICROSOFT VSUAL C#.NET | 6/19/2009

VENDOR HELP DESK Project Description:


VHD is an active helpdesk and a single window solution for enhancing vendors satisfaction level and provides hassle-free service to various departments and vendors. VHD provides a techno-driven approach in monitoring and maintaining the records of purchase orders, invoices and payments. Assist in prompt resolution of vendor queries regarding status of their purchase orders, invoices and payments. Moves invoices within the departments specifically and tracks their movements efficiently. Escalate vendor payments and inform the vendors via mail/phone about their payments. Always stay in touch and keeps reporting to various departments about the status of purchase orders, invoices and their movement and payments on daily basis.

MICROSOFT VSUAL C#.NET | 6/19/2009

Scope of Work: Receiving & recording Purchase Orders, Capex, Opex on daily basis. Receiving & recording Bills submitted by vendors.

49

Forwarding bills to users after allotting control number and receiving back. Query resolution with vendor & resubmission of bill to 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 and payments to vendors via mail/phone.

48

MICROSOFT VSUAL C#.NET | 6/19/2009

49

MICROSOFT VSUAL C#.NET | 6/19/2009

LOGIN FORM

MASTER DEPARTMENT FORM

48

MICROSOFT VSUAL C#.NET | 6/19/2009

49

MICROSOFT VSUAL C#.NET | 6/19/2009

MASTER VENDOR FORM

BILL MOVEMENT FORM

48

MICROSOFT VSUAL C#.NET | 6/19/2009

49

MICROSOFT VSUAL C#.NET | 6/19/2009

BILL ORDERS

SALES DEPARTMENTFORM

48

MICROSOFT VSUAL C#.NET | 6/19/2009

49

MICROSOFT VSUAL C#.NET | 6/19/2009

FINANCE DEPARTMENT FORM

VENDOR QUERY RESOLUTION

48

MICROSOFT VSUAL C#.NET | 6/19/2009

SCIENTIFIC AND STANDARD CALCULATOR

49

MICROSOFT VSUAL C#.NET | 6/19/2009

VENDORS REPORT

48

MICROSOFT VSUAL C#.NET | 6/19/2009

49

MICROSOFT VSUAL C#.NET | 6/19/2009

VENDOR HELP DESK BILL RECORDS

Вам также может понравиться