Tuesday, July 27, 2010

stuff function

STUFF (SQL Server Compact Edition)

Deletes a specified length of characters and inserts another set of characters at a specified starting point.

Syntax


STUFF ( character_expression, start, length, character_expression )

ROW_NUMBER :

Returns the sequential number of a row within a partition of a result set, starting at 1 for the first row in each partition.

Syntax


ROW_NUMBER ()     OVER ( [  ]  )

Friday, July 23, 2010

Dynamic menu control....

In aspx page:

Take asp:menu control....And add bellow code in code behind...

Code behind:

private void loadCategory()
{
DataTable category = new DataTable();

category = CategoryService.Gettopcategory();

DataTable subcat = new DataTable();
subcat = CategoryService.Getsubcategory();

DataView categoryView = new DataView(category);
DataView childCategoryView = new DataView(subcat);



if (categoryView.Count > 0)
{
foreach (DataRowView categoryRowView in categoryView)
{
MenuItem parentMenu = new MenuItem();
parentMenu.Text = categoryRowView["maincategory"].ToString();
parentMenu.Value = categoryRowView["categoryid"].ToString();

childCategoryView.RowFilter = "categoryid=" + (int)categoryRowView["categoryid"];


foreach (DataRowView childcategoryRow in childCategoryView)
{

MenuItem childMenu = new MenuItem();
childMenu.Text = childcategoryRow["subcategory"].ToString();
childMenu.Value = childcategoryRow["subid"].ToString();
//childMenu.NavigateUrl = "~/Default.aspx?CategoryID=" + childMenu.Value;
parentMenu.ChildItems.Add(childMenu);
//}
}
Menu2.Items.Add(parentMenu);
}

}


}

Thursday, July 15, 2010

.Net 2.0,3.0 and 3.5

NET framework 2.0:

It brings a lot of evolution in class of the framework and refactor control including the support of

Generics
Anonymous methods
Partial class
Nullable type
The new API gives a fine grain control on the behavior of the runtime with regards to multithreading, memory allocation, assembly loading and more
Full 64-bit support for both the x64 and the IA64 hardware platforms
New personalization features for ASP.NET, such as support for themes, skins and webparts.
.NET Micro Framework


.NET framework 3.0:

Also called WinFX,includes a new set of managed code APIs that are an integral part of Windows Vista and Windows Server 2008 operating systems and provides

Windows Communication Foundation (WCF), formerly called Indigo; a service-oriented messaging system which allows programs to interoperate locally or remotely similar to web services.
Windows Presentation Foundation (WPF), formerly called Avalon; a new user interface subsystem and API based on XML and vector graphics, which uses 3D computer graphics hardware and Direct3D technologies.
Windows Workflow Foundation (WF) allows for building of task automation and integrated transactions using workflows.
Windows CardSpace, formerly called InfoCard; a software component which securely stores a person's digital identities and provides a unified interface for choosing the identity for a particular transaction, such as logging in to a website


.NET framework 3.5:

It implement Linq evolution in language. So we have the folowing evolution in class:

Linq for SQL, XML, Dataset, Object
Addin system
p2p base class
Active directory
ASP.NET Ajax
Anonymous types with static type inference
Paging support for ADO.NET
ADO.NET synchronization API to synchronize local caches and server side datastores
Asynchronous network I/O API
Support for HTTP pipelining and syndication feeds.
New System.CodeDom namespace.

Connection Pooling Basics:

Connection Pooling Basics




Opening a database connection is a resource intensive and time consuming operation. Connection pooling increases the performance of Web applications by reusing active database connections instead of creating a new connection with every request. Connection pool manager maintains a pool of open database connections. When a new connection requests come in, the pool manager checks if the pool contains any unused connections and returns one if available. If all connections currently in the pool are busy and the maximum pool size has not been reached, the new connection is created and added to the pool. When the pool reaches its maximum size all new connection requests are being queued up until a connection in the pool becomes available or the connection attempt times out.

Connection pooling behavior is controlled by the connection string parameters. The following are four parameters that control most of the connection pooling behavior:

  • Connect Timeout - controls the wait period in seconds when a new connection is requested, if this timeout expires, an exception will be thrown. Default is 15 seconds.
  • Max Pool Size - specifies the maximum size of your connection pool. Default is 100. Most Web sites do not use more than 40 connections under the heaviest load but it depends on how long your database operations take to complete.
  • Min Pool Size - initial number of connections that will be added to the pool upon its creation. Default is zero; however, you may chose to set this to a small number such as 5 if your application needs consistent response times even after it was idle for hours. In this case the first user requests won't have to wait for those database connections to establish.
  • Pooling - controls if your connection pooling on or off. Default as you may've guessed is true. Read on to see when you may use Pooling=false setting.

Wednesday, July 14, 2010

Difference between Web Server and Application Server.

Difference between AppServer and a Web server
(1) Webserver serves pages for viewing in web browser, application server provides exposes businness logic for client applications through various protocols

(2) Webserver exclusively handles http requests.application server serves bussiness logic to application programs through any number of protocols.

(3) Webserver delegation model is fairly simple,when the request comes into the webserver,it simply passes the request to the program best able to handle it(Server side program). It may not support transactions and database connection pooling.

(4) Application server is more capable of dynamic behaviour than webserver. We can also configure application server to work as a webserver.Simply applic! ation server is a superset of webserver.


Web Server serves static HTML pages or gifs, jpegs, etc., and can also run code written in CGI, JSP etc. A Web server handles the HTTP protocol. Eg of some web server are IIS or apache.

An Application Server is used to run business logic or dynamically generated presentation code. It can either be .NET based or J2EE based (BEA WebLogic Server, IBM WebSphere, JBoss).

A J2EE application server runs servlets and JSPs (infact a part of the app server called web container is responsible for running servlets and JSPs) that are used to create HTML pages dynamically. In addition, J2EE application server can run EJBs - which are used to execute business logic.

An Application server has a 'built-in' web server, in addition to that it supports other modules or features like e-business integration, independent management and security module, portlets etc.


Difference between Web Server and Application Server.

A Web Server understands and supports only HTTP protocol whereas an Application Server supports HTTP,TCP/IP and many more protocols. Also many more features such as Caches,Clusters,Load Balancing are there in Application Servers which are not available in Web Servers. We can also Configure Application Servers to work as Web Server. In short, Applicaion Server is a super set of which Web Server is a sub set.

You can't run EJB or any business logic in Javawebserver. An application server should have the capability to run business logic in it. That's why we can't say that JWserver a application server.

The Web server:

A Web server handles the HTTP protocol. When the Web server receives an HTTP request, it responds with an HTTP response, such as sending back an HTML page. To process a request, a Web server may respond with a static HTML page or image, send a redirect, or delegate the dynamic response generation to some other program such as CGI scripts, JSPs (JavaServer Pages), servlets, ASPs (Active Server Pages), server-side JavaScripts, or some other server-side technology. Whatever their purpose, such server-side programs generate a response, most often in HTML, for viewing in a Web browser.

Understand that a Web server's delegation model is fairly simple. When a request comes into the Web server, the Web server simply passes the request to the program best able to handle it. The Web server doesn't provide any functionality beyond simply providing an environment in which the server-side program can execute and pass back the generated responses. The server-side program usually provides for itself such functions as transaction processing, database connectivity, and messaging.

While a Web server may not itself support transactions or database connection pooling, it may employ various strategies for fault tolerance and scalability such as load balancing, caching, and clustering—features oftentimes erroneously assigned as features reserved only for application servers.

Eg: Apache HTTP Server, Sun ONE Web Server, iPlanet Web Server

The application server:

As for the application server, according to our definition, an application server exposes business logic to client applications through various protocols, possibly including HTTP. While a Web server mainly deals with sending HTML for display in a Web browser, an application server provides access to business logic for use by client application programs. The application program can use this logic just as it would call a method on an object (or a function in the procedural world).

Such application server clients can include GUIs (graphical user interface) running on a PC, a Web server, or even other application servers. The information traveling back and forth between an application server and its client is not restricted to simple display markup. Instead, the information is program logic. Since the logic takes the form of data and method calls and not static HTML, the client can employ the exposed business logic however it wants.

In most cases, the server exposes this business logic through a component API, such as the EJB (Enterprise JavaBean) component model found on J2EE (Java 2 Platform, Enterprise Edition) application servers. Moreover, the application server manages its own resources. Such gate-keeping duties include security, transaction processing, resource pooling, and messaging.

Like a Web server, an application server may also employ various scalability and fault-tolerance techniques.

Few imp points in C++ and C#

1)Memory Management


The other difference is that there is no equivalent to C++ delete operator in C#. Instead, with C#, the .Net garbage collector periodically comes in and scans through the refrences in your code in order to identify which areas of the heap are currently in use by our program. It is then automatically able to remove all the objects that are no longer in use. This technique effectively saves you from having to free up nay memory yourself on the heap.

2)New control flow statement- for each

C# provides an additional flow control statement, for each. For each loops across all items in array or collection without requiring explicit specification of the indices.
Syntax:

Foreach(double someElement in MyArray)
{
Console.WriteLine(someElement);
}

3) Classes

Classes in C# follow much the same principles as in C++, though there are a few differences in both features and syntax.

Class MyClass : MyBaseClass
{
Private string SomeFiels;
Public in SomeMethod()
{
Return;
}

Classes defined in C# using what at first sight looks like much the same syntax as in C++, but there are numerous differences:

There is no access modifier on the name of the base class. Inheritance is always public.

A class can only be derived from one base class. If no base class is explicitly specified, then the class will automatically be derived from System.Object, which will give the class all the functionality of System.Object, the most commnly used of which is ToString().

In C++, the only types of class members are variables, functions, constructors, destructors and operator overloads, C# also permits delegates, events and properties.

The access modifiers public, private and protected have the same meaning as in C++ but there are two additional access modifiers available:


i. Internal
ii. Protected internal

C++ requires a semicolon after the closing brace at the end of a class definition. This is not required in C#.