affiliate_link

Tuesday, December 2, 2008

Executing a SQL script using ADO.NET

The following article is a good starting point

http://www.mattberther.com/2005/04/11/executing-a-sql-script-using-adonet/

Thursday, October 23, 2008

Difference between Stored Procedures and Views

Here are some of the differences between stored procedures and views

Stored Procedures

  • Can accept parameters
  • Can contain multiple statements (Select, insert, update, delete, loops, if else etc)
  • Can perform modifications to tables
  • Cannot use stored procedures in joins
Views
  • Cannot accept parameters
  • Have single select statement
  • Cannot perform modifications to tables
  • Views can be used in joins

Tuesday, October 14, 2008

Redirecting to a url after 5 seconds delay

It is often required to show client a message then redirect user to some other page after a certain interval. For this, simply add the following line in the head section of the html file.

< meta equiv="refresh" content="5;URL=http://www.theurl.com" >

Change theurl to your required url.

Monday, October 6, 2008

Getting screen resolution of client machine

Sometimes it is required to display to webpage according to the screen resolution of the client computer. It can be done easily in javascript using screen object of the window object.

Javascript code snippet

var width = window.screen.width;

var height = window.screen.height;

Thursday, October 2, 2008

Constructor and Destructor

Contructor
A constructor is a special kind of a method that is called whenever a class is initialized

VB.Net code snippet
    Public Sub New()
' Perform initialization
Debug.WriteLine("I am alive")
End Sub
Data can be passed to a constructor for more flexibility and power. Constructors with parameters are called parameterized constructors.

Destructor
Desctructor is a method that is called to cleanup resources.

Visual Basic .NET provides a Finalize destructor. This destructor is called when the .NET garbage collector determines that the object is no longer needed. There may be a delay between the time an object is terminated and the time the garbage collector actually destroys the object.

Tip
You should not normally use a Finalize destructor because of this delay and the additional processing required by the system to manage objects with a Finalize destructor. Use the Dispose destructor instead.

In order to better manage the resources used by your class, implement the IDisposable interface and the Dispose destructor:

VB.Net code snippet

    Implements IDisposable
Public Sub Dispose() Implements System.IDisposable.Dispose
' Perform termination
End Sub
This destructor is not called automatically, so it must be explicitly called as shown in the next section.

Tip The Dispose destructor is not required, but it is recommended. By implementing the Dispose destructor in every class, even if it does not do anything, developers can routinely call the Dispose method on any object.
   m_oCustomer.Dispose()
m_oCustomer = Nothing

What is an Object?

Object is an in-memory representation of a class

Declaring an object

C# code snippet

Customer oCust = new Customer();

What is a class?

A class is a logical grouping of attributes, properties or fields and methods.

Declaring a class

C# code snippet

public class Customer
{
public int ID;
public string name;
public string phone;

public Order GetLastOrder()
{
return new Order();
}
}

Wednesday, October 1, 2008

Generating pdf with php

There exists very little open source options for generating pdf with php but http://fpdf.org
is one easy to use and both IE and firefox compatible open source solution available which generates pdf files with pure php so its very easy to setup on your server.
The author claims that although the generation speed of the document is less than with PDFlib
but there is very small difference for small and medium sized pdf documents.
The site has good tutorials for beginners and manual for all the functions.

Wednesday, September 24, 2008

Difference between Varchar and Char data types?

Varchar is a variable length character data type whereas Char is a fixed length character data type. Because Varchar is a variable length data type therefore its size is the actual length of the data entered and not the maximum size of the column