Posts under - .NET / SQL Server 
Blog Home
  Multithreading in ASP.NET

Introduction
Performance and responsiveness are most the important key issues in the success of your web application. Do not relay heavly on your users to be patient. They typically quickly close unresponsive or frozen applications.
Sometimes you need to perform a long time task, that uses intensive CPU operations. Sometimes you are acquiring a database and waiting for the results. Not to mention when  you are performing an intensive I/O operations. As a result your, application will be dead with no response until this time consuming operation completes.

A common solution to this common problem is the use of multithreading. The .NET framework provides you with a class library that allows you to overcome this problem by using multithreading and asynchronous programming techniques. In multithreading technique, you can use the thread pool to acquire a new thread, or you can create it manually. This all depends on the level of control you want to have over... Read Full Post

Posted by Rajiv on Monday, March 02, 2009 at 12:34-PM under .NET / SQL Server
Post Comments (0) Back to Top


  Threading in ASP.NET

Threading is a technique used to give the user the impression that multiple tasks are executing at the same time. The .NET Framework provides us with many types that allow us to easily and quickly add multi-threading to our .NET Web application. I'll assume that you have some familiarity with ASP.NET and at least some experience with writing code in Visual Basic.

Through the tutorial we'll build a pretty simple Web application that should be a good example of some basic threading concepts. Basically we'll have 2 textboxes in which to enter a phrase, and to enter a time period in which you want the phrase to be rebuilt. Our Web threading application consists of 2 pages, one of which is the page that will start the thread, while the other is a results page that shows us the progress of our thread. The code provided should be very portable and allow you to implement your own threading application very quickly.

First, we need to import the System.Threading Namespace so we can... Read Full Post

Posted by Rajiv on Monday, March 02, 2009 at 11:53-AM under .NET / SQL Server
Post Comments (0) Back to Top


  Multithreading in .NET Application

Introduction:
Threads are also known as lightweight processes.  However, if we go into depth then we would know that a thread is not actually a process; rather it provides ways for executing different parts of a program.  Now let us discuss what it actually means by multithreading.  Multithreading (as the name suggests multi+threading) is nothing but an efficient execution of multiple threads at a time to enhance the performance of the application.  For example, we are doing a file copy operation with a status bar on UI indicating the completion percentage.  Here we need to keep track of how much file size is copied and at the same time we also need to advance the progress bar accordingly.  This can not be done efficiently in a single thread and you have to use multiple threads.

The above example shows just one instance where we are forced to use multithreading.  However, when we are not forced we can also use this for the... Read Full Post

Posted by Rajiv on Monday, March 02, 2009 at 11:53-AM under .NET / SQL Server
Post Comments (0) Back to Top


  The compiler failed with error code 2000

This is a known bug by Microsoft, which has been finxed in VS2005 and latest versions.

Description: Keep getting the error code BC2017 and fatal error BC2000 when running web applications that have project references to assemblies that are strong-named.

According to Microsoft, it only applies to VS2003 and has been fixed in VS2005.

Fix: If you receive this error in your web application (VS2003) then Re-Build the Solution (not just Build). It should resolve the Compilation Error "Compiler Error Message: The compiler failed with error code 2000."

Posted by Rajiv on Thursday, February 26, 2009 at 10:07-AM under .NET / SQL Server
Post Comments (0) Back to Top


  Security in .NET Impersonation

Impersonation in .Net allows you to run an application in a particular user account which is determined by you. Usually the account in which the application runs is ASPNET or NETWORK SERVICE depending on the version of IIS you are running in your machine.

With IIS 5.0 the ASPNET account is used and it is not possible to override this account in the web.config file. In the IIS 6.0 you can configure this in the web.config file so that you can run the application on a different user account.

In the web.config file you can include the line,
<identity impersonate = “true” /> to enable impersonation. You can also impersonate for a particular user with the syntax, <identity impersonate = “true” username = “user_name” password = “user_pwd” />

So with the configuration in the web.config file you can run the application under a different user account. Although you might have different authentication models the underlying account in which the application runs is not changed. The security context is not changed although authentication is a tool. With classic ASP, this is not possible.

Posted by Rajiv on Friday, February 20, 2009 at 07:43-AM under .NET / SQL Server
Post Comments (0) Back to Top


  XML Serialization in .NET Framework

XML Serialization can enable you to convert any common language runtime objects into XML documents or streams and vise versa. The XML Serialization makes it possible to convert XML documents into such a meaningful format that all programming languages can process the converted documents without any difficulty. It is also possible for you to transfer or transport the objects serialized to XML in an open standards compliant and platform agnostic manner.

 
 
The XML Serialization process in .NET Framework can make you to serialize objects into XML format that can conform to the specific XML Schema Definition (XSD) schema or even to the serialization format that has been defined in the SOAP specification. During any XML Serialization only the fields of objects that hold public properties alone are serialized. You must also be aware that during the XML Serialization it may not be possible all the time to preserve the type fidelity.

For instance, the Book object... Read Full Post

Posted by Rajiv on Thursday, February 19, 2009 at 04:29-PM under .NET / SQL Server
Post Comments (0) Back to Top


  What is ASP.NET MVC?

The Microsoft ASP.NET MVC framework is Microsoft’s newest framework for building web applications. The ASP.NET MVC framework was designed from the ground up to make it easier to build good software in the sense of good software discussed in this chapter.

The ASP.NET MVC framework was created to support pattern-based software development. In other words, the framework was designed to make it easier to implement software design principles and patterns when building web applications.

Furthermore, the ASP.NET MVC framework was designed to its core to support unit tests. Web applications written with the ASP.NET MVC framework are highly testable.

The fact that ASP.NET MVC applications are highly testable makes the ASP.NET MVC framework a great framework to use when practicing test-driven development.

MVC is a framework methodology that divides an application's implementation into three component roles: models, views, and controllers.

Posted by Rajiv on Thursday, February 19, 2009 at 02:58-PM under .NET / SQL Server
Post Comments (0) Back to Top


  Response.Flush METHOD ASP.NET

IIS5 enables buffering by default, therefore all the output from your ASP is actually sent to the browser only when the page completes its processing. In many cases this approach improves the overall processing speed, and indirectly makes for a more scalable site. However, buffering has two minor defects: (1) the end user might perceive a loss in speed, because she won't see any output until the page is complete, and (2) buffered output has to be maintained on the server, therefore your ASP application is going to take more memory than it would do if buffering were disabled. On server machines with an inadequate amount of memory, large HTML pages can reduce the overall performance.
Fortunately, you can solve both problems with judicious use of the Response.Flush method, that lets you flush the output buffer periodically when sending a large amount of data back to the client. For example, if you are sending back to the client data from thousands of records, you might flush the buffer... Read Full Post

Posted by Rajiv on Thursday, February 19, 2009 at 02:58-PM under .NET / SQL Server
Post Comments (0) Back to Top


  RowDataBound alternate of ItemDataBound in Gridview

In .NET Framework version 2.0 GridView.RowDataBound Event Occurs after a row in the GridView is data-bound but before it is rendered on the page.

The RowDataBound event is raised whenever a row in the GridView is bound to data.

This event provides an opportunity to access each row before the page is finally sent to the client for display. After this event is raised, the data item is nulled out and no longer available.

This event is raised for the header, the footer, and data rows.

In RowDataBound Even you can write your code as showen in examples:

Example:

if (e.Row.RowType == DataControlRowType.DataRow)
{
    img = e.Row.FindControl("...") as Image;
    img.ImageUrl = "../images/photo" + e.Row.Cells[3].Text;
}

Another Example of ItemDataBound in Datagrid Control:

private void OnItemDataBound(Read Full Post

Posted by Rajiv on Thursday, February 19, 2009 at 02:14-PM under .NET / SQL Server
Post Comments (0) Back to Top


  Oracle/PLSQL: NVL Function

In Oracle/PLSQL, the NVL function lets you substitute a value when a null value is encountered.

The syntax for the NVL function is:

NVL( string1, replace_with )

string1 is the string to test for a null value.

replace_with is the value returned if string1 is null.

Applies To:

Oracle 8i, Oracle 9i, Oracle 10g, Oracle 11g

Example #1:

select NVL(supplier_city, 'n/a')
from suppliers;

The SQL statement above would return 'n/a' if the supplier_city field contained a null value. Otherwise, it would return the supplier_city value.

Example #2:

select supplier_id,
NVL(supplier_desc, supplier_name)
from suppliers;

This SQL statement would return the supplier_name field if the supplier_desc contained a null value. Otherwise, it would return the supplier_desc.

Example... Read Full Post

Posted by Rajiv on Thursday, February 19, 2009 at 02:14-PM under .NET / SQL Server
Post Comments (0) Back to Top


  Oracle/PLSQL: Decode Function

In Oracle/PLSQL, the decode function has the functionality of an IF-THEN-ELSE statement.

The syntax for the decode function is:

decode( expression , search , result [, search , result]... [, default] )

expression is the value to compare.

search is the value that is compared against expression.

result is the value returned, if expression is equal to search.

default is optional. If no matches are found, the decode will return default. If default is omitted, then the decode statement will return null (if no matches are found).

Applies To:

  • Oracle 9i, Oracle 10g, Oracle 11g

For example:

You could use the decode function in an SQL statement as follows:

SELECT supplier_name,
 decode(supplier_id, 10000, 'IBM',
 10001, 'Microsoft',
 10002, 'Hewlett... Read Full Post

Posted by Rajiv on Thursday, February 19, 2009 at 02:14-PM under .NET / SQL Server
Post Comments (0) Back to Top


  About Just in time (JIT) compiler in .NET

The high level programming languages that need to be compiled require a runtime, so that the architecture on which the language runs is provided with details on how to execute its code. All the programming languages use its corresponding runtime to run the application. For example, to run an application developed using Visual Basic, the computer on which the application will be run must be installed with the Visual Basic runtime. The Visual Basic runtime can run only the applications developed with Visual Basic and not the ones developed with any other programming language like Java.
 
In the .NET Framework, all the Microsoft .NET languages use a common language runtime, which solves the problem of installing separate runtime for each of the programming languages. Microsoft .NET Common Language Runtime installed on a computer can run any language that is Microsoft .NET compatible.

The main advantage of the .NET Framework is the interoperability between different languages.... Read Full Post

Posted by Rajiv on Thursday, February 19, 2009 at 02:03-PM under .NET / SQL Server
Post Comments (0) Back to Top


  Globalization in .NET

Globalization refers to the process with which an application or software will be designed and developed so as to make it run across all platforms and all sites with minimum or no modification to the software application. The software is very amenable to customisation so as to suit to the location-specific conditions and it is also capable of providing information based on the varied inputs and the location-specific operating system.

Under any normal circumstance, there will be two processes in Globalization and they are customisation or localisation of the application and internationalizing the application codes so as to meet the standards of the local culture and other related matters.

In internationalization process the application code base will be same and the efforts will be on jobs such as translating, storing, retrieving and to make the application user friendly for the selected locale. In any given place the culture and the language will always be different and... Read Full Post

Posted by Rajiv on Thursday, February 19, 2009 at 02:03-PM under .NET / SQL Server
Post Comments (0) Back to Top


  Understanding Impersonation in ASP.NET

At times users access a resource as though they were someone else. This is known as impersonation. For example, if a web page has no access controls, then any user can access that web page. HTML pages, ASP pages, and components in version 3.0 and earlier can be accessed through two accounts named IUSR_machinename and IWAM_machinename. Both the accounts are set up during IIS installation, and are automatically added to all the folders in every web site on the server.
 
Anonymous access to a resource in IIS makes the task of identifying a user extremely difficult. But there is no need to authenticate a user in the case of IIS. When IIS receives a request for a web page or other resource that has permission for anonymous access, IIS treats the IUSR_machinename account as the user's account, to access the resources. If the resource requested by the user is an ASP page that uses a COM or COM+ component, that component is executed using the IWAM_machinename account.

In ASP.NET,... Read Full Post

Posted by Rajiv on Thursday, February 19, 2009 at 02:03-PM under .NET / SQL Server
Post Comments (0) Back to Top


  SQl Server 2005 enhancements.

1.  What are the new data types or enhanced data types in SQL Server 2005?? 

Microsoft SQL Server 2005 introduces a new data type, the XML data type.  The XML data type lets you store XML documents and fragments in a SQL Server database.  An XML fragment is an XML instance that is missing a single top-level element.  You can create columns and variables of XML type and store XML instanced in them.

In addition to the new XML data type, Microsoft SQL Server 2005 has enhanced three of the existing SQL Server data types, namely the VARCHAR(MAX), NVARCHAR(MAX) and VARBINARY(MAX) data types.  The VARCHAR(MAX) data type indicates that the maximum storage size for the VARCHAR data type is 2^31-1 bytes.  The NVARCHAR data types indicates that the maximum storage size fr the NVARCHAR data type is 2^31-1 bytes.  Lastly, the VARBINARY(MAX) data type indicates that the maximum storage size for the VARBINARY data type is 2^31-1... Read Full Post

Posted by Rajiv on Friday, September 14, 2007 at 10:59-AM under .NET / SQL Server
Post Comments (0) Back to Top


  DataSets and XML – A Perfect Combination

The disconnected data access model of ADO.NET is centered on DataSets. DataSets are the core of ADO.NET architecture and represent an in memory representation of the database. They can be used with a wide variety of data sources and contain one or more DataTable objects. These DataTable objects in turn comprise of one or more DataRows and DataColumns. While the DataTable object represents every table within a DataSet; the DataColumn and the DataRow objects represent the columns and rows within a DataTable. The DataSet class provides a seamless support for XML. Using XML, we can use the DataSet class in ADO.NET to perform the CRUD (Create, Read, Update and Delete) operations without an underlying database to store the data. This article discusses how we can use DataSets and XML - considered by many as a perfect combination to perform the CRUD operations devoid of any underlying database to hold data.

What are DataSets?

A DataSet... Read Full Post
Posted by Rajiv on Friday, August 24, 2007 at 05:41-PM under .NET / SQL Server
Post Comments (0) Back to Top


  New Features in ADO.NET 2.0

Microsoft's ADO.NET heralded the introduction of a disconnected mode of data access, enabling data exchange even across process boundaries efficiently. This is in sharp contrast to the earlier data access technologies with only connected data access mode of operation. It should be noted that ADO.NET supports both connected and disconnected mode of data access. The introduction of ADO.NET has come as a boon to the development community with excellent features such as, seamless support for XML and support for connection pooling, to name a few. This article introduces the reader to newly added features to ADO.NET 2.0 and discusses how they can improve the performance, scalability, and maintainability of applications.


Why ADO.NET 2.0?

With a view to mitigate the performance drawbacks of the earlier version of ADO.NET and add more flexibility, Microsoft has introduced more new features in ADO.NET 2.0 — features that have... Read Full Post

Posted by Rajiv on Friday, August 24, 2007 at 05:20-PM under .NET / SQL Server
Post Comments (0) Back to Top


  Working with Exceptions in ADO.NET

ADO.NET is a very rich data access technology with a plenty of powerful features - improved performance, an optimized SQL Provider, seamless support for XML and ability to work in connected and disconnected mode, to name a few. Handling exceptions properly is one of the prime concerns when working with any data access technologies. The new version of ADO.NET includes powerful support for working with exceptions efficiently. This article throws light on how to handle exceptions efficiently when working with ADO.NET and highlights the best practices that can be followed in this context.

What are Exceptions?

An exception is an error that occurs at runtime. If it is not handled properly, it terminates the normal flow of the program. According to MSDN, “An exception is any error condition or unexpected behavior encountered by an executing program. Exceptions can be raised because of a fault... Read Full Post
Posted by Rajiv on Friday, August 24, 2007 at 05:00-PM under .NET / SQL Server
Post Comments (0) Back to Top


  ASP.NET Tips

I'm Going to explain now on some Control tip and tricks which will help and increase the speed of the webpages.

1.Smart navigation

Smart navigation is a little-known Internet Explorer feature that enables the individual controls on your Web forms to maintain focus between postback, as well as allows you to suppress that flicker that occurs as you load the new page.
To turn on this little-known feature, simply set the smartNavigation property of your ASPX page to True. You can also apply the property to all project pages, by adding the <pages> tag to the following location within your Web.config file:

<configuration>
<system.web>
<pages smartNavigation="true"/>... Read Full Post

Posted by Rajiv on Tuesday, July 24, 2007 at 12:02-PM under .NET / SQL Server
Post Comments (0) Back to Top


  Managing SQL Server 2000 Transaction Log Growth

Most likely, the root cause for the continuous transaction log growth is related to the database recovery model being set to 'full' for user defined databases without issuing regularly scheduled transaction log backups.  The full recovery model configuration is maintaining all of the before and after records in the transaction log until the transaction log is backed up. 

With these items in mind, it is time to make some changes to your SQL Server user defined databases and get your transaction logs to a manageable size.  Let's walk through each of these steps one at a time.

Note - These commands can be run in SQL Server management tool of your choice and replace the '[YourDatabaseNameHere]' text with the needed user defined database name.
 
First, review the transaction log size prior to the shrinking process.

USE [YourDatabaseNameHere]
GO
SELECT *
FROM sysfiles
WHERE name LIKE '%LOG%'
GO 

Second,... Read Full Post

Posted by Rajiv on Friday, July 20, 2007 at 04:27-PM under .NET / SQL Server
Post Comments (0) Back to Top


  Understanding the Page Life Cycle in ASP.NET

When a web page is sent to the Web Server for processing, it goes through a sequence of steps before it finally gets displayed in the Web Browser. This article discusses these series of steps and events that occur in a page life cycle in ASP.NET.

From Web Browser to IIS

When a POST request is initiated from the client side, the Web Server traps the request and it is usually routed to an .aspx web page. The request is actually routed to the HTTP Pipeline, a chain of managed objects.

After the HTTP Page handler class is identified, the ProcessRequest () method is called which eventually fires the different page events in the life cycle of a web page. The sequence of events that takes place in the life cycle of a web page in ASP.NET is:

  1. Page_Init
  2. LoadViewState
  3. LoadPostData
  4. Page_Load
  5. RaisePostDataChangedEvent
  6. RaisePostBackEvent
  7. Page_PreRender
  8. SaveViewState
  9. Page_Render
  10. Page_UnLoad... Read Full Post
Posted by Rajiv on Tuesday, May 22, 2007 at 12:27-PM under .NET / SQL Server
Post Comments (0) Back to Top


  ASP.NET Security

Security is one of the most important concerns in application software development. Building a robust security model is one of the most important factors that drive the success of application software. As far as security in ASP.NET is concerned, three terms come into my mind, i.e., Authentication, Authorization and Impersonation. Put simply, authentication authenticates the user’s credentials and authorization relates to the resources that an authenticated user has access to. This article is the first in a series of articles on ASP.NET security and discusses these concepts and their applicability.

Let us start our discussion with a brief outline on the sequence of events are as far as authentication and authorization are concerned when a new request comes in. When a new request arrives at IIS, it first checks the validity of the incoming request. If the authentication mode is anonymous (default) then the request is authenticated automatically. But if the authentication mode is... Read Full Post

Posted by Rajiv on Tuesday, May 22, 2007 at 12:12-PM under .NET / SQL Server
Post Comments (0) Back to Top


  Updating online SQL 2005 database from local database using SSIS

Most of developers/programmers find it difficult to upload/update database to remote SQL Server 2005 database server as compared to SQL 2000 because they can't find DTS in SQL Server Management Studio Express.

There are different ways and tools to accomplish what you need based on what you feel comfortable with and what fits your update schedule:

  1. The analog to DTS in SQL Server 2005 is SSIS (SQL Server Integration Services). A simple way to create SSIS package to transfer your data is to start the SQL Server Import and Export Wizard (just right click your database and select Tasks, Export Data...) and follow the steps. On the Select Source Tables and Views screen you can click "Edit Mappings". There you have options to drop and re-create the destination tables and to enable identity insert. At the end you can execute immediately or save it as SSIS package to execute later.
  2. Use the Database Publishing Wizard. It is designed for deployment of local databases to remote hosting environments. The tool has both graphical and command line interfaces, and there is a way that you can update your database via a Web page.
Posted by Rajiv on Tuesday, May 08, 2007 at 10:10-AM under .NET / SQL Server
Post Comments (0) Back to Top


  How To Get Hard Disk Information Using WMI

This article is a brief description of how you can use Windows Management Instrumentation to get information about hard disks on your system. This article does noe go into details of WMI. You can refer to Micorosft Platform SDK for more information. But here we will show you can make use of System.Management namespace classes in .NET Framework to accomplish this task. The framework SDK does not give details on all the properties and classes that are exposed by WMI to accomplish various tasks. This article should get you started on usage of WMI in .Net framework.

Hard disk information is exposed by Win32_DiskDrive WMI class. This class exposes following properties to get information.

  • Availability
  • BytesPerSector
  • Capabilities
  • CapabilityDescriptions... Read Full Post
Posted by Rajiv on Tuesday, May 08, 2007 at 08:25-AM under .NET / SQL Server
Post Comments (0) Back to Top


  How to Get .NET Framework Version

This can be accomplished veru easily by making use of System.Environment class. This class has a property named Version. This returns the version of framework installed on the system. The information is stored in the following format.

major.minor[.build[.revision]]
The current version of framework is 2.0.50727. Therefore if you call this information and call ToString method on Version object, you will get the string representation of version information.

private void Page_Load(object sender, System.EventArgs e)
{
// Put user code to initialize the page here
if (!IsPostBack)
{
  Version vs = Environment.Version;
  Response.Write(vs.ToString());
}
}

Posted by Rajiv on Tuesday, May 08, 2007 at 07:10-AM under .NET / SQL Server
Read & Post Comments (1) Back to Top


Recent Blog Posts
Show All Posts



© Copyright 2009 All rights reserved, Rajiv Sharma
Home | Contact Me | Sitemap | Privacy Notice & Disclaimer
Visitor's IP Address:
44.192.79.149