Saturday, September 19, 2009

FLEX

RIA developers are making applications that people didn't think were possible. With Flex, you can create full enterprise-scale Web applications that have as much interactivity as the best desktop applications. Flex enables some exciting possibilities

What is FLEX?
Adobe Flex is an application development platform that you can use to build Rich Internet Applications (RIAs). Flex applications are Web-based, but they provide immersive levels of interactivity and rich media experiences that make them seem more like computer desktop programs than traditional Web applications. Flex is the ideal technology to use when you want to create complex data visualization, performance dashboards, multimedia experiences, and countless other interactive applications. RIAs are raising the bar for Web applications, and Flex is leading the way
Flex is an application development framework and toolset that you can use to create RIAs. These applications are delivered over the Internet by using the Flash Player.

What an RIA (Rich Internet Application?
It describes a new model for application development that separated the back-end data services from a rich front-end client. One of the cornerstones of RIA development is the ability to asynchronously load data within the application. Simple HTML Web pages require a full page refresh to load new data. RIAs, on the other hand, load data asynchronously, which means they can load chunks of data without requiring page refreshes and they keep track of the application state in memory. Flex applications are stateful clients, which means they store data about the current state of the application, such as the content of a shopping cart, in memory in the client..
RIAs usually load data by using eXtensible Markup Language (XML). Asynchronously loading XML is an integral part of all RIA technologies (not only Flex). Version 4 of Flash, which was released in 1999, was the first version of Flash that let developers load external XML data into Flash applications

HISTORY
Flex 1 and 1.5, were expensive server-based products. A license for Flex 1.5 cost about $15,000, and you had to deploy a server application that would compile your Flex applications and serve them to the user. These initial versions of Flex were based on Flash Player 7 and ActionScript 2, and the code editor was based on the Macromedia Dreamweaver editor.
Flex 2 marked a dramatic shift in the product line. Flex 2 was no longer a server technology at all; instead, Flex was a completely clientside product. The cost dropped dramatically, and Adobe rewrote the entire Flex framework and the Integrated Development Environment (IDE) from the ground up. Flex 2 was based on Flash Player 9 and ActionScript 3, which brought serious performance gains
Flex 3 added additional functionality to Flex Builder, such as refactoring and enhanced styling support, as well as new data visualization components in the Flex framework. Flex 3 also marked the official open-source release of the Flex SDK and Flex compiler. For more on the open-source aspect of Flex, visit http://opensource.adobe.com.
Flex 4, codenamed Gumbo (coming soon)

FLEX Components
§ Languages: ActionScript 3 and MXML
You use a combination of ActionScript, a scripting language, and MXML, a markup language, to create Flex applications. MXML is similar to HTML, so if you have experience creating HTML Web pages, then you should be able to figure out MXML pretty easily.
§ Component framework: Flex SDK
The Flex SDK (also known as the Flex framework) is a set of user interface components, such as lists, buttons, and charts, that you use to build Flex applications. The Flex SDK (with the exception of the charting package) is free and open source.
§ Integrated Development Environment (IDE): Flex Builder
You use Flex Builder to edit your code, compile your applications, debug your code, and profile performance. Flex Builder is an integrated development environment (IDE) sold by Adobe.
§ Cross-browser runtime: Flash Player
You deploy Flex applications in a Web browser with the Flash Player plug-in. You can also deploy Flex applications as standalone desktop applications by using the Adobe Integrated Runtime (AIR).

Microsoft's Silverlight platform and Sun's JavaFX are two RIA development products aimed directly at taking on Flex
FLASH VS FLEX
§ The Flex framework: Flash has its own component set that has some of the same functionality as the Flex SDK, but it does not provide as many components and does not include charting components, layout containers, and other framework features that are very useful for developing large applications.
§ MXML: You can use MXML markup to create your Flex applications, but this markup language is not available in Flash. Flash does use the same ActionScript 3 scripting language, however.
§ A powerful Integrated Development Environment (IDE): Flex Builder was designed specifically to build applications, as opposed to the Flash Authoring tool, which was originally designed to create animations. You can use both tools to create RIAs, but Flex Builder has features like code-hinting, a powerful debugger, and a profiler that make it a more powerful development tool.
You can use Flash, rather than Flex, to create RIAs, but you have to work in the Flash Authoring environment, which means you don't get the benefits of Flex Builder (such as code hinting), and you can't use the MXML markup language. You may find the Flash Authoring tool really helpful if you're creating animated movies. It uses the timeline metaphor when you create animations and includes drawing tools. Flex Builder, on the other hand, is designed for application development, not animation creation. Flex Builder doesn't include any drawing tools, and it has no timeline.

Flex VS Ajax
Asynchronous JavaScript and XML (AJAX) is a technique that you can use to load data into HTML Web pages without refreshing the full page. Instead of sending a new HTML page to the user's Web browser for every change, AJAX applications send XML asynchronously and update relevant portions of the screen when needed. By using AJAX, you often end up with a much more responsive user interface and a more desktop-like application experience. Flex applications also asynchronously load XML data.

ActionScript VS JavaScript
Multimedia capabilities: Flash Player allows you to create a whole range of rich multimedia experiences that you simply can't achieve by using HTML and JavaScript. Flash has powerful graphics capabilities that can do complex drawing and image manipulation. In addition, Flash supports audio and video streaming, so many leading online video sites use it to play video on the Web.
Cross-browser support: You can be sure that any Flex application you develop will look and behave the same way in all browsers on all platforms. Web browsers all have their own quirks and idiosyncrasies when it comes to how they render HTML and even how they run JavaScript. When you develop AJAX applications, you need to test your application in multiple Web browsers to make sure your application is compatible with them all. However, because Flex applications rely on the Flash Player, you can be assured that your application will look the same, pixel for pixel, and behave the same across all browsers.

Flex VS SilverLight
Microsoft's competitive RIA technology is Silverlight, a browser plug-in, like Adobe's Flash Player. Just like you have to install the Flash Player plug-in to run Flex applications, you need the Silverlight plug-in to run Silverlight applications. Because Silverlight is fairly new, the Silverlight plug-in isn't nearly as common as Flash Player. Silverlight will likely become more widely used in the future, but right now, the Flash Player plug-in has a strong advantage because of the large number of computers on which it is installed.
The first release of Silverlight 1.0 included the browser plug-in and focused on streaming video on the Web. This release certainly competed with Flash Player because it focused on some of the media features of Flash, but it didn't really threaten Flex's position because Silverlight 1.0 didn't contain a set of user interface controls that you could use to build RIAs. Silverlight 1.0 provided all the low-level graphics capabilities but none of the application frame-work pieces.
In early 2008, Microsoft released the first beta version of Silverlight 2.0 (originally named Silverlight 1.1), which included a set of UI controls, such as a DataGrid, CheckBox, and Slider. These new controls make Silverlight a closer competitor with Flex. The competition between Flex and Silverlight has just begun, and it's too early to draw any firm conclusions about how serious a competitor Silverlight will become.
AIR (Adobe Integrated Runtime)
Adobe developed Adobe Integrated Runtime (AIR), previously code-named Apollo, to let you deploy Flex applications as computer desktop applications. By using AIR, you can create your own desktop applications that can run natively on Windows, Mac, and Linux operating systems. You can create AIR applications as Flex applications or AJAX applications, so if you know how to create Flex or AJAX applications, you can create desktop applications, too.
When deciding whether AIR is the right technology for your application, consider these three main features that AIR provides:
§ Local file-system access: One of the main reasons for moving from a Web-based Flex application to a desktop AIR application is the integrated local file-system access that AIR offers. If you build a Flex-based AIR application, you get a few extra tools that don't come in the normal Flex framework. These tools let you read and write to the user's local file system.
§ Integrated Web browser: The AIR runtime includes a built-in Web browser: the open-source WebKit browser. This Web browser allows you to load full HTML pages right into your application, something that you can't do in a Web-based Flex application. The AIR framework also lets you display PDF files within your application.
§ Embedded SQLite database: AIR applications can access an embedded database for offline database access. So, you can build applications that can connect to a server database (like a typical Flex application can) or to an offline database if your application is only occasionally connected to the Internet

Friday, September 18, 2009

XML

What is XML?
XML, Extensible Markup Language, is an open, text based markup language that provides structural and semantic information to data. XML is a metalanguage that can be used to create other language. It is used to structure and describe data that can be understood by other applications. Using XML, we can separate the user interface from data.

Features of XML ?
XML is a generalized markup language that means one can define his/her own tag sets.A valid XML document contains rules and is self-describing.The rules that are found in DTD allow the documents to be validated.


Describe the logical structure of XML.
XML documents comprise of declaration, elements and comments

XML Declaration
It identifies the version to which XML conforms


Document Type Declaration
It consists of markup code that indicates grammar rules or Document Type Definition (DTD) for the particular class of document.

This statement tells the XML processor that the document is of the class Car that conforms the rules specified in the DTD "cr.dtd".

Document element
The document element contains data of an XML document.


Why is XML so popular?
Due to the following advantages of using XML, it has become popular:
It supports Unicode. Therefore documents written in any human language can be communicated.
Data structures: records, lists and trees can be represented using XML.
Its format describes structure, field names and their specific values too. Its therefore called self-documenting.
Its syntax and parsing requirements make the necessary parsing algorithms very simple, efficient, and consistent.
It can be used as a document storage and processing format.
It is platform-independent.

HTTP Protocol

What information is contained in HTTP Header?
From client

Header data that consists of configuration information about the client and its document viewing preferences
From server
header from the server contains information about the server software and the document sent to the client.

Authentication

What are the various ways of authentication techniques in ASP.NET?
Selecting an authentication provider is as simple as making an entry in the web.config file for the application. You can use one of these entries to select the corresponding built in authentication provider:



√ Custom authentication where you might install an ISAPI filter in IIS that compares incoming requests to list of source IP addresses, and considers requests to be authenticated if they come from an acceptable address. In that case, you would set the authentication mode to none to prevent any of the .net authentication providers from being triggered.


Windows authentication and IIS If you select windows authentication for your ASP.NET application, you also have to configure authentication within IIS. This is because IIS provides Windows authentication. IIS gives you a choice for four different authentication methods: ----------------Anonymous,basic,digest and windows integrated
If you select anonymous authentication, IIS doesn’t perform any authentication, Any one is allowed to access the ASP.NET application.
If you select basic authentication, users must provide a windows username and password to connect. How ever this information is sent over the network in clear text, which makes basic authentication very much insecure over the internet.
If you select digest authentication, users must still provide a windows user name and password to connect. However the password is hashed before it is sent across the network. Digest authentication requires that all users be running Internet Explorer 5 or later and that windows accounts to stored in active directory.
If you select windows integrated authentication, passwords never cross the network. Users must still have a username and password, but the application uses either the Kerberos or challenge/response protocols authenticate the user. Windows-integrated authentication requires that all users be running internet explorer 3.01 or later Kerberos is a network authentication protocol. It is designed to provide strong authentication for client/server applications by using secret-key cryptography. Kerberos is a solution to network security problems. It provides the tools of authentication and strong cryptography over the network to help to secure information in systems across entire enterprise

Passport authentication
Passport authentication lets you to use Microsoft’s passport service to authenticate users of your application. If your users have signed up with passport, and you configure the authentication mode of the application to the passport authentication, all authentication duties are off-loaded to the passport servers.
Passport uses an encrypted cookie mechanism to indicate authenticated users. If users have already signed into passport when they visit your site, they’ll be considered authenticated by ASP.NET. Otherwise they’ll be redirected to the passport servers to log in. When they are successfully log in, they’ll be redirected back to your site
To use passport authentication you have to download the Passport Software Development Kit (SDK) and install it on your server. The SDK can be found at http:// msdn.microsoft.com/library/default.asp?url=/downloads/list/websrvpass.aps. It includes full details of implementing passport authentication in your own applications.

Forms authentication
Forms authentication provides you with a way to handle authentication using your own custom logic with in an ASP.NET application. The following applies if you choose forms authentication.
√ When a user requests a page for the application, ASP.NET checks for the presence of a special session cookie. If the cookie is present, ASP.NET assumes the user is authenticated and processes the request.
√ If the cookie isn’t present, ASP.NET redirects the user to a web form you provide201 You can carry out whatever authentication, it check’s you like it checks your form. When the user is authenticated, you indicate this to ASP.NET by setting a property, which creates the special cookie to handle subsequent requests.

Validation Controls

How many types of validation controls are provided by ASP.NET ?
There are six main types of validation controls :-

RequiredFieldValidator It checks whether the control have any value. It's used when you want the control should not be empty.
RangeValidator It checks if the value in validated control is in that specific range.
Example TxtCustomerCode should not be more than eight length.
CompareValidator It checks that the value in controls should match some specific value. Example Textbox TxtPie should be equal to 3.14.
RegularExpressionValidator When we want the control value should match with a specific regular expression.
CustomValidator It is used to define UserDefined validation.
ValidationSummary It displays summary of all current validation errors.

Indexer

What is Indexer ?
An indexer is a member that enables an object to be indexed in the same way as an array.

OOP

What is Object Oriented Programming ?
It is a problem solving technique to develop software systems. It is a technique to think real world in terms of objects. Object maps the software model to real world concept. These objects have responsibilities and provide services to application or other objects.


What’s a Class ?
A class describes all the attributes of objects, as well as the methods that implement the behavior of member objects. It’s a comprehensive data type which represents a blue print of objects. It’s a template of object.


What’s an Object ?
It is a basic unit of a system. An object is an entity that has attributes, behavior, and identity. Objects are members of a class. Attributes and behavior of an object are defined by the class definition.


What is the relation between Classes and Objects ?
They look very much same but are not same. Class is a definition, while object is a instance of the class created. Class is a blue print while objects are actual objects existing in real world. Example we have class CAR which has attributes and methods like Speed, Brakes, Type of Car etc. Class CAR is just a prototype, now we can create real time objects which can be used to provide functionality. Example we can create a Maruti car object with 100 km speed and urgent brakes


What are different properties provided by Object-oriented systems ?

Abstraction It allows complex real world to be represented in simplified manner. Example color is abstracted to RGB. By just making the combination of these three colors we can achieve any color in world.It’s a model of real world or concept.
Encapsulation It is a process of hiding all the internal details of an object from the outside world.
Communication using messages When application wants to achieve certain task it can only be done using combination of objects. A single object can not do all the task. Example if we want to make order processing form.We will use Customer object, Order object, Product object and Payment object to achieve this functionality. In short these objects should communicate with each other. This is achieved when objects send messages to each other.
Object lifetime All objects have life time.Objects are created ,and initialized, necessary functionalities are done and later the object is destroyed. Every object have there own state and identity which differ from instance to instance.
Class hierarchies (Inheritance and aggregation) Twist :- What is difference between Association, Aggregation and Inheritance relationships? In object oriented world objects have relation and hierarchies in between them. There are basically three kind of relationship in Object Oriented world :-
Association This is the simplest relationship between objects. Example every customer has sales. So Customer object and sales object have an association relation between them. Aggregation This is also called as composition model. Example in order to make a "Accounts" class it has use other objects example "Voucher", "Journal" and "Cash" objects. So accounts class is aggregation of these three objects.
Inheritance Hierarchy is used to define more specialized classes based on a preexisting generalized class. Example we have VEHICLE class and we can inherit this class make more specialized class like CAR, which will add new attributes and use some existing qualities of the parent class. Its shows more of a parent-child relationship. This kind of hierarchy is called inheritance.
Polymorphism When inheritance is used to extend a generalized class to a more specialized class, it includes behavior of the top class(Generalized class). The inheriting class often implement a behavior that can be somewhat different than the generalized class, but the name of the behavior can be same. It is important that a given instance of an object use the correct behavior, and the property of polymorphism allows this to happen automatically.


What are abstract classes ?
Following are features of a abstract class :-
√ You can not create a object of abstract class175
√ Abstract class is designed to act as a base class (to be inherited by other classes). Abstract class is a design concept in program development and provides a base upon which other classes are built.
√ Abstract classes are similar to interfaces. After declaring an abstract class, it cannot be instantiated on its own, it must be inherited.
√ In VB.NET abstract classes are created using "MustInherit" keyword.In C# we have "Abstract" keyword.
√ Abstract classes can have implementation or pure abstract methods which should be implemented in the child class.


what are Interfaces?
Interfaces are components used to declare a set of methods. However, the data members of an interface are not implemented. C# allows you to group related data by using structs. However, to group related methods, properties, indexers, and events, you use interfaces. Interfaces contain only method declarations; therefore, you cannot create an instance of an interface. However, you need to declare an interface by using the interface keyword. interface
{
- - - - - - - - - - - - - - - - -
}
Interface declarations do not include a modifier because all interfaces are public by default. Interfaces cannot be abstract, sealed, virtual, or static. However,you can use the new modifier with nested interfaces. The new modifier is used when you need to hide an inherited namespace by the same name as the base namespace. In situations where you want the members of a class to exhibit certain features, you can group these members in an interface. The class can then implement the
interface. The classes in C# can also implement multiple interfaces. Implementing an interface implies that a class is derived from the interface and the class implements all the members of that interface. Consider the following example of the Employee class that implements two interfaces:

interface Employee
{
- - - - - - - - - - - -
}
interface Salary
{
- - - - - - - - - - - -
}
class Employee: Employee, Salary
{
- - - - - - - - - - - -
}
Therefore, the class Employee implements all the methods declared in the interfaces
Employee and Salary.
Similar to classes, interfaces can also be inherited. These interfaces are called explicit base interfaces. C# does not support multiple inheritance of classes. However, you can achieve multiple inheritance in C# by using interfaces. In the previous example, if the interface Salary was inherited from Employee, the interface declaration statement would be:
interface Salary: Employee
{
- - - - - - - - - - - -
}
In C#, if a class implements an interface, the class also implicitly implements its base interfaces.
TIP By now, you have learned about the basic components of C# that you can use to write programs in C#. The next sections look at writing a simple program in C# and then compiling and executing it.

Thursday, September 17, 2009

SQL

Increase SQL performance?

  • Every index increases the time takes to perform INSERTS, UPDATES and
    DELETES, so the number of indexes should not be too much. Try to use
    maximum 4-5 indexes on one table, not more. If you have read-only table,
    then the number of indexes may be increased

    Keep your indexes as narrow as possible. This reduces the size of the index
    and reduces the number of reads required to read the index.
    (2) Try to create indexes on columns that have integer values rather than character
    values.
    (3) If you create a composite (multi-column) index, the order of the columns in
    the key are very important. Try to order the columns in the key as to enhance
    selectivity, with the most selective columns to the leftmost of the key.
    (4) If you want to join several tables, try to create surrogate integer keys for this
    purpose and create indexes on their columns.
    (5)Create surrogate integer primary key (identity for example) if your table will
    not have many insert operations.
    (6)Clustered indexes are more preferable than nonclustered, if you need to select
    by a range of values or you need to sort results set with GROUP BY or ORDER
    BY.
    (7)If your application will be performing the same query over and over on the
    same table, consider creating a covering index on the table.
    (8)You can use the SQL Server Profiler Create Trace Wizard with "Identify Scans
    of Large Tables" trace to determine which tables in your database may need
    indexes. This trace will show which tables are being scanned by queries instead
    of using an index.

What’s difference between "Optimistic" and "Pessimistic" locking ?
In pessimistic locking when user wants to update data it locks the record and till then no one can update data. Other user’s can only view the data when there is pessimistic locking. In optimistic locking multiple users can open the same record for updating, thus increase maximum concurrency. Record is only locked when updating the record. This is the most preferred way of locking practically. Now a days browser based application is very common and having pessimistic locking is not a practical solution.


What is a candidate key ?
A table may have more than one combination of columns that could uniquely identify the rows in a table; each combination is a candidate key. During database design you can pick up one of the candidate keys to be the primary key.
For example, in the supplier table supplierid and suppliername can be candidate key but you will only pick up supplierid as the primary key.

What are the different types of joins? What is the difference between them ?
INNER JOIN Inner join shows matches only when they exist in both tables.
Example, in the below SQL there are two tables Customers and Orders and the inner join in made on Customers Customerid and Orders Customerid.So this SQL will only give you result with customers who have orders.If the customer does not have order it will not display that record.
SELECT Customers.*, Orders.* FROM Customers INNER JOIN Orders ON Customers.CustomerID =Orders.CustomerID

LEFT OUTER JOIN Left join will display all records in left table of the SQL statement.In SQL below customers with or without orders will be displayed. Order data for customers without orders appears as NULL values. For example, you want to determine the amount ordered by each customer and you need to see who has not ordered anything as well. You can also see the LEFT OUTER JOIN as a mirror image of the

RIGHT OUTER JOIN if you switch the side of each table.
SELECT Customers.*, Orders.* FROM Customers LEFT OUTER JOIN Orders ON Customers.CustomerID =Orders.CustomerID278

RIGHT OUTER JOIN Right join will display all records in right table of the SQL statement. In SQL below all orders with or without matching customer records will be displayed. Customer data for orders without customers appears as NULL values.
For example, you want to determine if there are any orders in the data with undefined CustomerID values (say, after a conversion or something like it). You can also see the RIGHT OUTER JOIN as a mirror image of the LEFT OUTER JOIN if you switch the side of each table. SELECT Customers.*, Orders.* FROM Customers RIGHT OUTER JOIN Orders ON Customers.CustomerID =Orders.CustomerID

What are indexes? What is the difference between clustered and nonclustered indexes?
Indexes in SQL Server are similar to the indexes in books. They help SQL Server retrieve the data quickly. There are clustered and nonclustered indexes. A clustered index is a special type of index that reorders the way in which records in the table are physically stored. Therefore table can have only one clustered index. The leaf nodes of a clustered index contain the data pages. A nonclustered index is a special type of index in which the logical order of the index does not match the physical stored order of the rows on disk. The leaf node of a nonclustered index does not consist of the data pages. Instead, the leaf nodes contain index rows.

Design Patterns


What are design patterns ?
Design patterns are recurring solution to recurring problems in software architecture.

Design Patterns are basically divided into 3 classifactions.
Creational patterns.
Structural patterns.
Behavioral patterns.

1) Creational Patterns
√ Abstract Factory:- Creates an instance of several families of classes
√ Builder :- Separates object construction from its representation
√ Factory Method:- Creates an instance of several derived classes
√ Prototype:- A fully initialized instance to be copied or cloned
√ Singleton:- A class in which only a single instance can exist
Note :- The best way to remember Creational pattern is by ABFPS (Abraham Became First President of States).


2) Structural Patterns
√ Adapter:-Match interfaces of different classes.
√ Bridge:-Separates an object’s interface from its implementation.
√ Composite:-A tree structure of simple and composite objects.
√ Decorator :-Add responsibilities to objects dynamically.
à Fa̤ade:-A single class that represents an entire subsystem.
√ Flyweight:-A fine-grained instance used for efficient sharing.
√ Proxy:-An object representing another object. 8..NET Architecture229
Note : To remember structural pattern best is (ABCDFFP)


3) Behavioral Patterns
√ Mediator:-Defines simplified communication between classes.
√ Memento:-Capture and restore an object's internal state.
√ Interpreter:-A way to include language elements in a program.
√ Iterator:-Sequentially access the elements of a collection.
√ Chain of Resp:-A way of passing a request between a chain of objects.
√ Command:-Encapsulate a command request as an object.
√ State:-Alter an object's behavior when its state changes.
√ Strategy:-Encapsulates an algorithm inside a class.
√ Observer:-A way of notifying change to a number of classes.
√ Template Method:-Defer the exact steps of an algorithm to a subclass.
√ Visitor:-Defines a new operation to a class without change.
Note :- Just remember Music....... 2 MICS On TV (MMIICCSSOTV). Note:- No source code is provided for architecture section as much of the things can be clear from good UML diagrams.


What is MVC pattern?
The main purpose using MVC pattern is to decouple the GUI from the Data. It also gives the ability to provide multiple views for the same Data. MVC pattern separates objects in to three important sections:-
Model: - This section is specially for maintaining data. It is actually where your business logic, querying database, database connection etc. is actually implemented.
Views: - Displaying all or some portion of data, or probably different view of data. View is responsible for look and feel, Sorting, formatting etc.
Controller: - They are event handling section which affects either the model or the view. Controller responds to the mouse or keyboard input to command model and view to change. Controllers are associated with views. User interaction triggers the events to change the model, which in turn calls some methods of model to update its state to notify other registered views to refresh their display.

MVC sections:-
Model: - This section is represented by Data view, Dataset, Typed Dataset, Business components, business entity models etc. Now this section can then be tied up to either windows application or web UI.
View: - ASPX, ASCX, or windows application UI like data grid etc. form the view part of it.
Controller: - In ASP.NET the behind code is the controller as the events are handled by that part. Controller communicates both with Model as well as view. I hope I was able to map you imagination of ASP.NET with the diagram given below.


How can we implement singleton pattern in .NET?
Singleton pattern mainly focuses on having one and only one instance of the object running. Example a windows directory service which has multiple entries but you can only have single instance of it through out the network.
Note:- May of developers would jump to a conclusion saying using the "STATIC" keyword we can have a single instance of object. But that’s not the real case there is something more that has to be done. But please note we can not define a class as STATIC, so this will not serve our actual purpose of implementing singleton pattern.

Following are the three steps needed to implement singleton pattern in .NET:-
√ First create your class with static members.
Public class ClsStaticClass
Private shared objCustomer as clsCustomer
End class
This ensures that there is actually only one Customer object throughout the project.
√ Second define a private constructor to your class. Note: - defining a private constructor to class does not allow a client to create objects directly.
√ Finally provide a static method to get access to your singleton object.

Wednesday, September 16, 2009

Linking Servers


A QUESTION CAN BE ASKED HOW TO CALL A STORED PROCEDURE OF ORACLE DATABASE FROM SQLSERVER DATABASE STORED PROCEDURE
A linked server configuration enables SQL Server to execute commands against OLE DB data sources on remote servers

Linked servers offer the following advantages:
  1. Remote server access.
  2. The ability to issue distributed queries, updates, commands, and transactions on heterogeneous data sources across the enterprise.
  3. The ability to address diverse data sources similarly.

Typically, linked servers are used to handle distributed queries. When a client application executes a distributed query through a linked server, SQL Server parses the command and sends requests to OLE DB. The rowset request may be in the form of executing a query against the provider or opening a base table from the provider.
For a data source to return data through a linked server, the OLE DB provider (DLL) for that data source must be present on the same server as the instance of SQL Server.
When a third-party OLE DB provider is used, the account under which the SQL Server service runs must have read and execute permissions for the directory, and all subdirectories, in which the provider is installed.

Sharepoint 2007

What is SharePoint?
SharePoint is an enterprise information portal, from Microsoft, that can be configured to run Intranet, Extranet and Internet sites. Microsoft Office SharePoint Server 2007 allows people, teams and expertise to connect and collaborate. A SharePoint enterprise portal is composed of both SharePoint Portal and Windows SharePoint Services, with SharePoint being built upon WSS. WSS is typically used by small teams, projects and companies. SharePoint Server is designed for individuals, teams and projects within a medium to large company wide enterprise portal.

What is Microsoft Windows SharePoint Services? How is it related to Microsoft Office SharePoint Server 2007?
Windows SharePoint Services is the solution that enables you to create Web sites for information sharing and document collaboration. Windows SharePoint Services -- a key piece of the information worker infrastructure delivered in Microsoft Windows Server 2003 -- provides additional functionality to the Microsoft Office system and other desktop applications, and it serves as a platform for application development.

Office SharePoint Server 2007 builds on top of Windows SharePoint Services 3.0 to provide additional capabilities including collaboration, portal, search, enterprise content management, business process and forms, and business intelligence.


Why should you use SharePoint?
• As companies grow so does the amount of their files. It soon becomes difficult to keep track of the multiplying documents and their locations. SharePoint overcomes this by allowing you to store and share your files in a central site.
• Sharing work files through email is a cumbersome process. SharePoint eliminates this by allowing files to be stored in one location, allowing easy access to all team members.
• Business Intelligence has traditionally remained in the hands of a few key decision makers within organizations. For years, it has been the goal of BI providers to “democratize business intelligence” by making it available to all levels of workers throughout companies. With the addition of PerformancePoint to the SharePoint Enterprise version of SharePoint, this vision is realized, finally taking business intelligence out of the hands of the few and into the hands of many.
• Today’s work occurs over multiple locations, whether it is in different countries, office locations, separate departments or at your home office. SharePoint enables teams and individuals to connect and collaborate together regardless of where they are located.
• Surveys have shown that employees can spend up to 20 – 30 % of their day searching for data and information. SharePoint eliminates this drag on productivity by providing the robust search functionality needed to find the information and expertise buried in the thousands, or hundreds of thousands of files a company generates in the course of business.
• It’s difficult and time consuming to create and maintain sites. SharePoint allows anyone to create sites for use within their company’s Intranet, as they are needed, whether they are departmental sites, document libraries, meetings sites, survey sites, or discussion boards.

Microsoft Office SharePoint Server 2007 Top 10 Benefits?

Provide a simple, familiar, and consistent user experience
.
Office SharePoint Server 2007 is tightly integrated with familiar client desktop applications, e-mail, and Web browsers to provide a consistent user experience that simplifies how people interact with content, processes, and business data. This tight integration, coupled with robust out-of-the-box functionality, helps you employ services themselves and facilitates product adoption.

Boost employee productivity by simplifying everyday business activities.
Take advantage of out-of-the-box workflows for initiating, tracking, and reporting common business activities such as document review and approval, issue tracking, and signature collection. You can complete these activities without any coding. Tight integration with familiar client applications, e-mail, and Web browsers provide you with a simple, consistent experience. Modifying and extending these out-of-the-box workflow processes is made easy through tools like Microsoft Office SharePoint Designer 2007 (the next release of Microsoft Office FrontPage).

Help meet regulatory requirements through comprehensive control over content.
By specifying security settings, storage policies, auditing policies, and expiration actions for business records in accordance with compliance regulations, you can help ensure your sensitive business information can be controlled and managed effectively. And you can reduce litigation risk for your organization. Tight integration of Office SharePoint Server 2007 with familiar desktop applications means that policy settings are rendered onto client applications in the Microsoft Office system, making it simpler for employees to be aware of and comply with regulatory requirements.

Effectively manage and repurpose content to gain increased business value.
Business users and content authors can create and submit content for approval and scheduled deployment to intranet or Internet sites. Managing multilingual content is simplified through new document library templates that are specifically designed to maintain a relationship between the original version and different translations of a document.

Simplify organization-wide access to both structured and unstructured information across disparate systems.
Give your users access to business data found in common line-of-business systems like SAP and Siebel through Office SharePoint Server 2007. Users can also create personalized views and interactions with business systems through a browser by dragging configurable back-end connections. Enterprise-wide Managed Document Repositories help your organizations store and organize business documents in one central location.

Connect people with information and expertise.
Enterprise Search in Office SharePoint Server 2007 incorporates business data along with information about documents, people, and Web pages to produce comprehensive, relevant results. Features like duplicate collapsing, spelling correction, and alerts improve the relevance of the results, so you can easily find what you need.

Accelerate shared business processes across organizational boundaries.
Without coding any custom applications, you can use smart, electronic forms–driven solutions to collect critical business information from customers, partners, and suppliers through a Web browser. Built-in data validation rules help you gather accurate and consistent data that can be directly integrated into back-end systems to avoid redundancy and errors that result from manual data re-entry.

Share business data without divulging sensitive information.
Give your employees access to real-time, interactive Microsoft Office Excel spreadsheets from a Web browser through Excel Services running on Office SharePoint Server 2007. Use these spreadsheets to maintain and efficiently share one central and up-to-date version while helping to protect any proprietary information embedded in the documents (such as financial models).

Enable people to make better-informed decisions by presenting business-critical information in one central location. /
Office SharePoint Server 2007 makes it easy to create live, interactive business intelligence (BI) portals that assemble and display business-critical information from disparate sources, using integrated BI capabilities such as dashboards, Web Parts, scorecards, key performance indicators (KPIs), and business data connectivity technologies. Centralized Report Center sites give users a single place for locating the latest reports, spreadsheets, or KPIs.

Provide a single, integrated platform to manage intranet, extranet, and Internet applications across the enterprise.
Office SharePoint Server 2007 is built on an open, scalable architecture, with support for Web services and interoperability standards including XML and Simple Object Access Protocol (SOAP). The server has rich, open application programming interfaces (APIs) and event handlers for lists and documents. These features provide integration with existing systems and the flexibility to incorporate new non-Microsoft IT investments.

Top 10 Benefits of Windows SharePoint Services?

Improve team productivity with easy-to-use collaborative tools
Connect people with the information and resources they need. Users can create team workspaces, coordinate calendars, organize documents, and receive important notifications and updates through communication features including announcements and alerts, as well as the new templates for creating blogs and wikis. While mobile, users can take advantage of convenient offline synchronization capabilities.

Easily manage documents and help ensure integrity of content
With enhanced document management capabilities including the option to activate required document checkout before editing, the ability to view revisions to documents and restore to previous versions, and the control to set document- and item-level security, Windows SharePoint Services can help ensure the integrity of documents stored on team sites.

Get users up to speed quickly
User interface improvements in Windows SharePoint Services 3.0 include enhanced views and menus that simplify navigation within and among SharePoint sites. Integration with familiar productivity tools, including programs in the Microsoft Office system, makes it easy for users to get up to speed quickly. For example, users can create workspaces, post and edit documents, and view and update calendars on SharePoint sites, all while working within Microsoft Office system files and programs.

Deploy solutions tailored to your business processes
While standard workspaces in Windows SharePoint Services are easy to implement, organizations seeking a more customized deployment can get started quickly with application templates for addressing specific business processes or sets of tasks.

Build a collaboration environment quickly and easily
Easy to manage and easy to scale, Windows SharePoint Services enables IT departments to deploy a collaborative environment with minimal administrative time and effort, from simple, single-server configurations to more robust enterprise configurations. Because deployment settings can be flexibly changed, less pre-planning time is required and companies can get started even faster.

Reduce the complexity of securing business information
Windows SharePoint Services provides IT with advanced administrative controls for increasing the security of information resources, while decreasing cost and complexity associated with site provisioning, site management, and support. Take advantage of better controls for site life-cycle management, site memberships and permissions, and storage limits.

Provide sophisticated controls for securing company resources
IT departments can now set permissions as deep down as the document or item level, and site managers, teams, and other work groups can initiate self-service collaborative workspaces and tasks within these preset parameters. New features enable IT to set top-down policies for better content recovery and users, groups, and team workspace site administration.

Take file sharing to a new level with robust storage capabilities
Windows SharePoint Services supplies workspaces with document storage and retrieval features, including check-in/check-out functionality, version history, custom metadata, and customizable views. New features in Windows SharePoint Services include enhanced recycle bin functionality for easier recovery of content and improved backup and restoration.

Easily scale your collaboration solution to meet business needs
Quickly and easily manage and configure Windows SharePoint Services using a Web browser or command-line utilities. Manage server farms, servers, and sites using the Microsoft .NET Framework, which enables a variety of custom and third-party administration solution offerings.

Provide a cost-effective foundation for building Web-based applications
Windows SharePoint Services exposes a common framework for document management and collaboration from which flexible and scalable Web applications and Internet sites, specific to the needs of the organization, can be built. Integration with Microsoft Office SharePoint Server 2007 expands these capabilities further to offer enterprise-wide functionality for records management, search, workflows, portals, personalized sites, and more.

Creating an auidence in MOSS 2007
Audience are groups of users that are assigned memberships in icrosoft exchange distribution lists (DLs) or sharepoint group. DLs support communication and enhance the productivity of the users. A portal manager can assign membership to users by configuring rules.In MOSS 2007 rules for auidence are based on user profile on membership in the Active directory. \
An auidence can be group of employees. Usinf auidences enables orgnizations to provide suitable contents to group of users according to their job and task requirement. You can target content so that only users in perticular auidences can view
1) Web Part :different auidences use different web parts
2) Web part items : targeting at list item level.
3) Navigation controls : targeted to different auidence.

MOSS 2007 supports targetting based on rule-based auidences, Sharepoint groups and DL memberships. The namespace in the object model that supports audiences is Microsoft.Office.Server.Audience (contained in Microsoft.Office.Server.dll). for backward compatibility the Microsoft .Sharepoint.Portal.Audience namespace is still supported. And you get an warning message when you use these metnods.



What are the two base classes a WebPart you are going to use within SharePoint 2007 can inherit from?
There are two base classes that a WebPart which is going to be consumed by SharePoint can inherit from, either the SharePoint WebPart Base class or the ASP.NET 2.0 WebPart base class. When inheriting from the SharePoint WebPart Base class your derived WebPart class will inherit from Microsoft.SharePoint.WebPartPages.WebPart. When inheriting from the ASP.NET 2.0 WebPart base class your derived WebPart class will inherit from System.Web.UI.WebControls.WebParts.WebPart. It is considered good practice to use the ASP.NET WebPart base class since the old base class is meant for backwards compatibility with previous version of SharePoint, however there are four exception when it is better to leverage functionality from the SharePoint WebPart base class:

Cross page connections
Connections between Web Parts that are outside of a Web Part zone
Client-side connections (Web Part Page Services Component)
Data caching infrastructure


What are the differences between the two base classes and what are the inherit benefits of using one over another?

The difference is the Microsoft.SharePoint.WebPartPages.WebPart base class is meant for backward compatibility with previous versions of SharePoint. The benefit of using the SharePoint WebPart base class is it supported:

Cross page connections
Connections between Web Parts that are outside of a Web Part zone
Client-side connections (Web Part Page Services Component)
Data caching infrastructure

ASP.NET 2.0 WebParts are generally considered better to use because SharePoint is built upon the ASP.NET 2.0 web architecture. Inheriting from the ASP.NET 2.0 base class offers you features that inherit to ASP.NET 2.0, such as embedding resources as opposed to use ClassResources for deployment of said types.

What is the GAC?

The GAC stands for the global assembly cache. It is the machine wide code cache which will give custom binaries place into the full trust code group for SharePoint. Certain SharePoint assets, such as Feature Receivers need full trust to run correctly, and therefore are put into the GAC. You should always try to avoid deployment to the GAC as much as possible since it will possibly allow development code to do more than it was intended to do.

What is strong naming (signing) a WebPart assembly file mean?

Signing an assembly with a strong name (a.k.a strong naming) uses a cryptographic key pair that gives a unique identity to a component that is being built. This identity can then be referred throughout the rest of the environment. In order to install assemblies into the GAC, they must be strongly named. After signing, the binary will have a public key token identifier which can be use to register the component in various other places on the server.

Tuesday, September 8, 2009

WSE 2.0

The Web Services Enhancements for Microsoft .NET (WSE) enables you to develop secure, interoperable Web services that are based on open industry specifications for .NET Framework applications. WSE enables this type of development by implementing the WS-* specifications to provide end-to-end message level security.

WSE 2.0's new messaging API enables Web Services to take a much needed first step towards message transport independence by enabling the sending of SOAP messages via TCP with no dependence on IIS or HTTP.

In the standard .ASMX pipeline, SOAP messages are tightly tied to the HTTP transport. WSE 2.0 includes a new Messaging API that delivers on SOAP's original intent by separating the message from the transport protocol. WSE 2.0 includes support for sending SOAP messages via TCP or HTTP with the ability to extend the infrastructure to include other transport mechanisms. These features combined with the implementation of the WS-Addressing Specification allows for true peer-to-peer communication using SOAP messages.While the examples listed on the article show how to create and use these new features at a fairly low level including dispatching of the incoming messages,
it also introduces the SOAPClient and SOAPService classes from which you can easily create components that communicate across process or machine boundaries.

Interoperable with Windows Communication Foundation
WSE-enabled clients will interoperate with Windows Communication Foundation (WCF). Additionally, WCF clients will interoperate with WSE 3.0-enabled Web services. WSE 3.0 is wire-level-compatible with WCF using the HTTP protocol and the corresponding turnkey security scenarios. Interoperability is not guaranteed with other protocols such as TCP.

Simplification of Web services security
WSE simplifies the security model in previous versions of WSE by introducing a set of turnkey security assertions. Instead of applying security to SOAP messages on a per SOAP message basis, these turnkey security assertions are designed to be applied apply to SOAP message exchanges that are based upon the distributed application's scenario.

Thursday, September 3, 2009

WPF

WPF(Windows Presentation Foundation) is the engine that is responsible for creating, displaying, and manipulating user-interfaces, documents, images, movies, and media in Windows Vista and upper versions.


Physically, WPF is a set of libraries that have all functionalty you need to build, run, execute, and manage Windows Vista applications.


Expression Blend
Expression Blend is mainly for the ponytail set (artistic types who prefer Macs) to create vector-based, animated, and three-dimensional graphics — much the way they do in Photoshop. Blend has a rich set of brushes, palettes, paint buckets, text, gradients, timelines, and event triggers for those with the skill to take advantage of them.
The XML-based files that Blend generates work in Windows Presentation Foundation (WPF) applications that run on Windows and in cross-platform Silverlight apps for the Web.

Tuesday, September 1, 2009

C# Features


C# 2.0
· Generics
· Nullable types
· Iterators
· Partial class definitions
· Anonymous methods
· The :: operator
· static classes
· Covariance and contravariance
· Fixed-size buffers
· Friend assemblies
· extern aliases
· Method group conversions

C# 3.5

  1. Auto Implemented Properties
  2. Local Type Inference (var keyword)
  3. Object and Collection Initializers
  4. Anonymous Types
  5. Extension Methods
  6. Lambda Expressions
  7. Introduction to LINQ to Objects
  8. LINQ Projection
  9. LINQ Where Clause
  10. LINQ From and Join
  11. LINQ Ordering and Grouping
  12. LINQ Set Operations
  13. LINQ Quantifiers



C# 4.0 Language features:
Dynamic Type
Visual C# 2010 provides support for late binding to dynamic types by introducing a new type, dynamic. This addition enables many new scenarios, including simplified access to COM APIs such as the Office Automation APIs, to dynamic APIs such as IronPython libraries, and to the HTML Document Object Model (DOM).
Visual C# 2010 introduces a new type, dynamic. The type is a static type, but an object of type dynamic bypasses static type checking. In most cases, it functions like it has type object. At compile time, an element that is typed as dynamic is assumed to support any operation. Therefore, you do not have to be concerned about whether the object gets its value from a COM API, from a dynamic language such as IronPython, from the HTML Document Object Model (DOM), from reflection, or from somewhere else in the program. However, if the code is not valid, errors are caught at run time





Auto Implemented Properties

==========================





Auto Implemented Properties provide a short-cut to creating the verbose getter and setter methods, as well as the accompanying private fields used when creating classes.




In pastwe used to wirte get and set properties to access the private variables, As we generally store values of properties in private fields.




private int orderID;




public int OrderID {




get { return orderID; }




set {orderID = value; }




}







So if we have 100 properties then we have to write the same code for 100 times , depending upon the properties being implemented in the class.




The same thing has been reduced with the help of Auto implementing properties in C# 3.0




so the same code above can be changed as below:




public int OrderID {get; set; }




so thereis no need to store the private field like above, as that is all done implecetly through the use of this syntax




ALSO there is another short cut on top of this short cut as CODE SNIPPET




prop TAB TAB (write prop and hit TAB 2 times)




public int property { get; set;}




for readonly property




propg TAB TAB (write propg and hit TAB 2 times)




public int property { get; private set; }




Local Type Inference

==============================




Also known as implicitly typed local variables




This introduces the var keyword to C# 3.0, and it isused basically as an easy way to create a variable without having to knowthe type. This introduces the var keyword to C# 3.0, and it isused basically as an easy way to create a variable without having to knowthe type. When we work with LINQ, many times it may not be very clear whata given linq query is returning, and so the var keyword allows us to say "we don't really care what it is, let C# figure it out."




e.g





var first =7;
Console.WriteLine("First variable type: {0}",first.GetType());



O/P System.Int32 so it seems that first is of type Int32




var second = 7;
Console.WriteLine("Second variable type: {0}", second.GetType());



O/P System.Int32 so it seems that var is same as object but that is not TRUE
it is boxed up and unboxed whenever its referenced.



to prove that we do



int third=second //error as cann't do this implectly but can be done explectly



int third=first;



Console.WriteLine("Third variable type: {0}", third.GetType());



so this proves its not same as boxing and unboxing



And the moral is var infers the actal type there is no boxing , and its completely type safe.

Now the things which you cann't do

  • var may only appear within a local variable declaration, so var has to be used within the context of an method.
  • you cann't use var as an input parameter for a method.
  • you cann't use it as a return type.
  • the value for the var variable has to be initalised, so that it know what type to be created for the variable.
  • you cann't assign null to a var variable.

Object and Collection Initializers

=========================

Object initializers let you assign values to any accessible fields or properties of an object at creation time without having to explicitly invoke a constructor. These work similiarly to an initialized array, where we're able to set the properties of a newly created object or multiple instances of new objects in a new collection in essentially one line of code. In someways it's similar to a constructor that populates the properties of a newlyinstance of an object. However, unline a constructor, you can pick andchoose which properties to populate in any combination.

private class Cat{

// Auto-implemented properties

public int Age { get; set; }

public string Name { get; set; }

}

static void MethodA()

{

// Object initializer

Cat cat = new Cat { Age = 10, Name = "Sylvester" };

}

Collection initializers let you specify one or more element intializers when you initialize a collection class that implements IEnumerable. The element initializers can be a simple value, an expression or an object initializer. By using a collection initializer you do not have to specify multiple calls to the Add method of the class in your source code; the compiler adds the calls.

e.g The following collection initializer uses object initializers to initialize objects of the Cat class defined in an earlier example. Note that the individual object initializers are enclosed in braces and separated by commas.

List cats = new List

{

new Cat(){ Name="Sylvester", Age=8 },

new Cat(){ Name="Whiskers", Age=2},

new Cat() { Name="Sasha", Age=14}

null

};

You can specify null as an element in a collection initializer if the collection's Add method allows it

Differences

What is the difference between delegate and events?
√ Actually events use delegates in bottom. But they add an extra layer on the delegates, thus forming the publisher and subscriber model.
√ As delegates are function to pointers they can move across any clients. So any of the clients can add or remove events, which can be pretty confusing. But events give the extra protection by adding the layer and making it a publisher and subscriber model.
Just imagine one of your clients doing this c.XyzCallback = null This will reset all your delegates to nothing and you have to keep searching where the error is.


What are similarities between Class and structure ?
Following are the similarities between classes and structures :-
√ Both can have constructors, methods, properties, fields, constants, enumerations, events, and event handlers. √ Structures and classes can implement interface.
√ Both of them can have constructors with and without parameter.
√ Both can have delegates and events.

What is the difference between Class and structure’s ?
Following are the key differences between them :-
√ Structure are value types and classes are reference types. So structures use stack and classes use heap.
√ Structures members can not be declared as protected, but class members can be. You can not do inheritance in structures.
√ Structures do not require constructors while classes require.
√ Objects created from classes are terminated using Garbage collector. Structures are not destroyed using GC.


What is the difference between System.String and System.StringBuilder classes?
System.String is immutable;
System.StringBuilder can have mutable string where a variety of operations can be performed.


What is the difference between "Web.config" and "Machine.Config" ?

"Web.config" files apply settings to each web application, while "Machine.config" file apply settings to all ASP.NET applications.


What is the difference between Server.Transfer and response.Redirect ?
Following are the major differences between them:-
√ Response.Redirect sends message to the browser saying it to move to some different page, while server.transfer does not send any message to the browser but rather redirects the user directly from the server itself. So in server.transfer there is no round trip while response.redirect has a round trip and hence puts a load on server.
√ Using Server.Transfer you can not redirect to a different from the server itself. Example if your server is www.yahoo.com you can use server.transfer to move to www.microsoft.com but yes you can move to www.yahoo.com/travels, i.e. within websites. This cross server redirect is possible only using Response.redirect.
√ With server.transfer you can preserve your information. It has a parameter called as "preserveForm". So the existing query string etc. will be able in the calling page.


What is the difference between Authentication and authorization?
These two concepts seem altogether similar but there is wide range of difference. Authentication is verifying the identity of a user and authorization is process where we check does this identity have access rights to the system. In short we can say the following authentication is the process of obtaining some sort of credentials198 from the users and using those credentials to verify the user’s identity.
Authorization is the process of allowing an authenticated user access to resources. Authentication always proceed to Authorization; even if your application lets anonymous users connect and use the application, it still authenticates them as being anonymous.

Transaction

TRANSACTIONS
A transaction symbolizes code or a set of components or procedures which must be executed as a unit. All the methods must execute successfully or the complete unit fails. A transaction can be described to cover the ACID properties for any applications
What are the ACID Properties?
Atomicity
Consistency
Isolation
Durability
e..g. which will transfer a specified amount from one account to another

transaction should be rolled back (Cancelled) if :
There are insufficient funds in the From Account to cover the transfer.

Either of the SQL statements
for marking credit or debit in the To and From accounts results in an error.
execute the two SQL queries one to subtract the amount from the From Account and one to add the same amount to the balance in the To Account.
We start the transaction after we have created the data objects
.The transaction should be kept as short as possible to avoid concurrency issues and to enable maximum number of positive commits.
SqlCommand command = connection.CreateCommand();
SqlTransaction transaction = null;

try
{
// BeginTransaction() Requires Open Connection
connection.Open();

transaction = connection.BeginTransaction();

// Assign Transaction to Command
command.Transaction = transaction;

// Execute 1st Command
command.CommandText = "Insert ...";
command.ExecuteNonQuery();

// Execute 2nd Command
command.CommandText = "Update...";
command.ExecuteNonQuery();

transaction.Commit();
}
catch
{
transaction.Rollback();
throw;
}
finally
{
connection.Close();
}



How can we perform transactions in .NET?
The most common sequence of steps that would be performed while developing a transactional application is as follows:
√ Open a database connection using the Open method of the connection object.
√ Begin a transaction using the Begin Transaction method of the connection object. This method provides us with a transaction object that we will use later to commit or rollback the transaction. Note that changes caused by any queries executed before calling the Begin Transaction method will be committed to the database immediately after they execute. Set the Transaction property of the command object to the above mentioned transaction object.
√ Execute the SQL commands using the command object. We may use one or more command objects for this purpose, as long as the Transaction property of all the objects is set to a valid transaction object. √ Commit or roll back the transaction using the Commit or Rollback method of the transaction object.
√ Close the database connection.