Archive

Archive for 25 January 2008

Fight corruption in India

25 January 2008 Steve Leave a comment

Categories: Articles

Difference between ASP.NET Server Controls and HTML Server Controls

25 January 2008 Steve Leave a comment

Advantages:

1. ASP .NET Server Controls can detect the target browser’s capabilities and render themselves accordingly. No issues for compatibility issues of Browsers i.e page that might be used by both HTML 3.2 and HTML 4.0 browsers code is written in the Server Controls.

2. Newer set of controls that can be used in the same manner as any HTML control like Calender controls. Without any need of Activex Control without bringing up issues of Browser compatibility).

3. Processing would be done at the server side. In built functionality to check for few values(with Validation controls) so no need to choose between scripting language which would be incompatible with few browsers.

4. ASP .NET Server Controls have an object model different from the traditional HTML and even provide a set of properties and methods that can change the outlook and behavior of the controls.

5. ASP .NET Server Controls have higher level of abstraction. An output of an ASP .NET server control can be the result of many HTML tags that combine together to produce that control and its events. Example Gridview or Form control.

Disadvantages:

1. The control of the code is inbuilt with the web server controls so you have no much of direct control on these controls

HTML Server Controls

Advantages:

1. The HTML Server Controls follow the HTML-centric object model. Model similar to HTML

2. Here the controls can be made to interact with Client side scripting. Processing would be done at client as well as server depending on your code.

5. A HTML Server Control has similar abstraction with its corresponding HTML tag and offers no abstraction.

Disadvantages:

1. You would need to code for the browser compatibility.

2. The HTML Server Controls have no mechanism of identifying the capabilities of the client browser accessing the current page.

How to find the last identity value inserted in the SQL Server

25 January 2008 Steve 1 comment

When inserting a row in the database with an identity column as a primary key, most of the time we need to capture the new identity value generated. In SQL Server there cane as many as three approaches for the same.

@@IDENTITY

SCOPE_IDENTITY()

IDENT_CURRENT(‘tablename’)

All of them can be used to find the last identity value inserted in the database, but they differ in the functionality depending on the scope or source of the insert as well as the connection that insert the row.

The server variable @@IDENTITY will return the last generated identity value accross all scope but for the same connection. The value returned will be for the last table inserted with identity column in the same connection. This means that if we insert some record in table (TableA) which has a trigger on the insert and the trigger inserts a record in some other table (TableB) with identity column then the @@IDENTITY will return the identity value inserted in TableB.

Function SCOPE_IDENTITY() is identical to @@IDENTITY with one exception. The value returned is limited to the current scope (i.e. the executed stored procedure). So in our previous example the value returned will the identity value inserted in TableA.

Finally, function IDENT_CURRENT spans all scope and all connections to retrieve the last generated table identity value. But the function is table specific and returns the value for the given table only.

Categories: SQL Server

How to change the maximum number of character displayed in SQL server Query analyzer and Management studio

25 January 2008 Steve 1 comment

One of the very simple and common that one of the commenter asked me a few days ago was why does the SQL query analyzer show only results unto 255 character only and not full column text. This is common to any data type in SQL server Query Analyzer.

The maximum number of character displayed using the tools->Option menu. Go to the result Tab and change the ‘Maximum characters per column’. BY default the value is set to 255. The maximum value allowed here is 8192 character.

In SQL Management studio (for SQL server 2005) go to Tools->Options, expand Query Results / SQL Server / Results to Text, and change the setting for “Maximum number of characters displayed in each column.. Note that in Results to Grid, you can send 65,535characters; however, results to text is still limited to 8,192 character only

Categories: SQL Server