PROGRAMMER DESK

Accept Changes To Develop Good Solutions

Embed Google Search in Your Custom Applications

Embed Google Search in Your Custom Applications

Written by – Vinay Hatwal

Dt. 03-Jul-2009

 

Dear all,

This time I came with the topic “Embed Google Search in Your Custom Applications”. With this we can embed Google search in our application. First of all I will discuss the tools which you need to install on your PC to use the Google Search

 

  • .Net Framework 3.5
  • Google Search API for .NET 0.2  (GoogleSearchAPI_0.2.zip)
  • GoogleSearchAPI_0.2.zip
  • GoogleSearchAPI.dll

 

 

Steps to do

 

1)      Create a new project with vb.Net 2.0 or 3.5.(Windows Application)

2)      Add Reference of GoogleSearchAPI.dll

3)      Add following controls

  1. RichTextBox  – RichTextBox1
  2. Label- Label1
  3. TextBox- TextBox1         
  4. Button- Button1

4)      Your Interface will look like

inter1

 

5)      Add the following coding in your Form1.cs file

 

 

 

Public Class Form1

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

        ‘Declaring Generic IList for IWebResult Interface

        ‘You can use -

        ‘1) IWebResult

        ‘2) IVideoResult

        ‘3) INewsResult

        ‘4) INewsResult

        ‘5) IImageResult

        ‘ AND MORE

        Dim results As IList(Of Google.API.Search.IWebResult)

 

        ‘Taking result

        ‘calling of Google.API.Search.GwebSearcher.Search(search text, Number of search result would be returned at a time)

        results = Google.API.Search.GwebSearcher.Search(TextBox1.Text, 10)

        Dim str As String = “”

        RichTextBox1.Text = “”

        For Each r As Google.API.Search.IWebResult In results

            ‘Fetching Title

            str = str & “Title :” & r.Title & vbCrLf

            ‘Fetching URL

            str = str & “URL :” & r.Url & vbCrLf

            ‘Fetching VisibleUrl

            str = str & “VisibleUrl :” & r.VisibleUrl & vbCrLf

            ‘Fetching Content

            str = str & “Content :” & r.Content & vbCrLf

            str = str & “=========================================================================================” & vbCrLf

        Next

        RichTextBox1.Text = str

    End Sub

End Class

 

 

6)      Now Enter the text to search on text box and click on Go. The result will look like –

Search Result

July 3, 2009 Posted by vinayhatwal | Embed Google Search in Your Custom | , , , | No Comments Yet

Inheritance

Inheritance

Written by – Vinay Hatwal

Dt. 16-Jun-2009

                                                                               

Inheritance is the OOPs concept in which new classes form from the existing classes i.e. using the class functionality in the new classes. Inheritance was first introduced in 1967 for Simula, a language which was used for simulation so the name is Simula.

Inheritance is intended to help reuse existing code with little or no modification. Inheritance is also sometimes called generalization, because the is-a relationships represent a hierarchy between classes of objects.

For Example, A “vehicle” is the generalization of “Car”, “Scooter”, “Bus” etc and the “Car”, “Scooter”, ”Bus” are the specialization of the “Vehicle”. Because the “Car” is a Vehicle so “Car” naturally inherits properties common to the entire vehicle like Color, No of Wheels, and EnginPower etc.

Following example show the inheritance in action. Shape is the Base Class and Square , Rectangle amd Circle are the classes derived from Shape Class and inherits all the functionality of the Shape class the shows the specialisation of the Shape Class.

Inheritance

Inheritance

Inheritance in Action

—————————————————————

VB.NET

—————————————————————

Public Class BaseClass

 

End Class

 

 

Public Class DerivedClass

    Inherits BaseClass

 

End Class

—————————————————————

 

—————————————————————

C#.NET

—————————————————————

public class BaseClass

{

}

 

public class DerivedClass : BaseClass

{

}

 

—————————————————————

 

 

 

Above DerivedClass Will contain all the inheritable funtionality of the BaseClass. Inheritane can be used in

 

VB.NET – Inherits

C#.NET – :

 

 

 

Access Specifires

 

Functionality VB.NET C#.NET
Gives variable public access which means that there is no restriction on their accessibility Public public
Gives variable private access which means that they are accessible only within their declaration content Private private
Protected access gives a variable accessibility within their own class or a class derived from that class Protected protected
Gives variable friend access which means that they are accessible within the program that contains their declaration Friend internal
Gives a variable both protected and friend access Protected Friend protected internal
Makes a variable static which means that the variable will hold the value even the procedure in which they are declared ends Static static
Declares a variable that can be shared across many instances and which is not associated with a specific instance of a class or structure Shared static
Makes a variable only to be read and cannot be written ReadOnly -

 

 

Keywords used in Inheritance in VB.NET/C#

 

1)      MustInherit, MustOverride /abstract

2)      Overridable/virtual

3)      Overrides/override

4)      NonInheritable/sealed

5)      Shadows/New

 

Concepts Regarding Interitance

1)      Abstraction

Abstraction is “the process of identifying common patterns that have systematic variations; an abstraction represents the common pattern and provides a means for specifying which variation to use” (Richard Gabriel).

In Abstraction we will look only on the keywords

a)      MustInherit, MustOverride /abstract

 

Abstract Classes or MustInherit class can not me instantiated. The can only be inherited in the derived class.

For Example –

 

—————————————————————

VB.NET

—————————————————————

 

Public MustInherit Class Base

    Public Sub NormalMethod()

    End Sub

    Public MustOverride Sub MustOverridableMethod()

End Class

 

 

Public Class Derived

    Inherits Base

    Public Overrides Sub MustOverridableMethod()

 

    End Sub

End Class

 

 

—————————————————————

 

 

—————————————————————

C#.NET

—————————————————————

 

public abstract class Base

{

        public void NormalMethod()

        {

        }

        public abstract void MustOverridableMethod();

}

   

  public class Derived : Base

  {

 

      public override void MustOverridableMethod()

              {

              throw new NotImplementedException();

      }

}

 

—————————————————————

 

 

In the above example if you are declaring the method as MustOverride/ abstract then u have to give definition of that method in the derived class. But if you are defining the method in the MustInherit/Abstract class then you may or may not define this method in the derived class.

 

 

 

b)      Overridable/virtual and Overrides/override

 

Overridable/virtual is used to polimorphically declare the base class method. A non overridable/not virtual method can not me polymorfically declared in the base class because it will hide the base class method in the derived class (Refer to Shadowing).

When we declare a Overridable/virtual method, it must contain a method body. Other wise the compiler will generate an error. Remember that, since Overridable/virtual methods are used for achieving polymorphism and since polymorphism works only with objects, it not possible to declare a static method as virtual in C#. Similarly the private methods are also not possible to declare virtual, since they can’t override inside a derived class.

 

For Example –
—————————————————————

VB.NET

—————————————————————

 

Public Class PolyBase

    Public Overridable Function GetName() As String

        Return “Base Polymorphic Class”

    End Function

End Class

 

Public Class PolyDerived

    Inherits PolyBase

    Public Overrides Function GetName() As String

        Return “Derived Polymorphic Class”

    End Function

End Class

 

—————————————————————

 

 

—————————————————————

C#.NET

—————————————————————

 

public class PolyBase

    {

        public virtual string GetName()

        {

            return “Base Polymorphic Class”;

        }

    }

 

    public class PolyDerived : PolyBase

    {

        public override string GetName()

        {

            return “Derived Polymorphic Class”;

        }

    }

—————————————————————

 

 

2)      Sealed Classes –

 

Sealed Class can be instanciated but can not be inherited in another class .In VB.Net NotInheritable keyword is used to declare a class Seald and In C#.Net it is declared by sealed.

 

—————————————————————

VB.NET

—————————————————————

 

Public NotInheritable Class NotInheritableClass

    Public Function Fun1() As String

        Return “My class can not be inherited”

    End Function

End Class

—————————————————————

 

 

—————————————————————

C#.NET

—————————————————————

 

sealed class NonInheritableClass

       {

        public string Fun1()

        {

            return “this class can not be inherited”;

        }

}

—————————————————————

 

 

 

 

3)      Shadowing

In .Net it is possible to declare the member of the base class with the same name in the derived class. In this class we are actully hiding the base class member in the derived class , if u do so then .Net compiler will show a warning.

Consider the following example-

 

—————————————————————

VB.NET

—————————————————————

sh

—————————————————————

 

 

 

—————————————————————

C#.NET

—————————————————————

ssss

—————————————————————

 

 

See the compiler warning closely.

In VB.Net it is clearly advising to use the Shadows with the new Fun1() to hide the base class functionality. Here the correct code is -

—————————————————————

VB.NET

—————————————————————

 

Public Class Base

    Private x As Integer

    Private y As Integer

    Public Function Fun1() As Integer

        Return x + y

    End Function

End Class

 

 

Public Class Derived

    Inherits Base

    Public Shadows Function Fun1() As Integer

        Return 10

    End Function

End Class

—————————————————————

 

Shadows keyword hides the base class functionality and warning too.

 

And in the C# it is advising to use the new keyword to hide the base class method. Here the correct code is-

 

—————————————————————

C#.NET

—————————————————————

 

class Base

    {

        private  int x = 10;

        private int y = 20;

        public int Fun1()

        {

            return x + y;

        }

    }

   

    class Derived : Base

    {

        public new int Fun1()

        {

            return 10;

        }

    }

 

—————————————————————

 

__________________________________________________________________________

 

June 16, 2009 Posted by vinayhatwal | Inheritance | , , , , , , , , , , , , , , | No Comments Yet

New Features in Microsoft VS 2010

New Features in Microsoft VS 2010

 

 

Cloud Development

With Windows Azure Tools for Microsoft Visual Studio, developers can build, debug and deploy services and applications for Azure, the new cloud environment Microsoft announced in October 2008.

 

 

Web Development

In Visual Studio 2010, Microsoft is continuing their investment in great web development tools. Visual Studio 2010 enhancements for web developers include:

·         A high-performance and standards-compliant JavaScript, IntelliSense® engine

·         ‘One Click Deployment’ for quickly and easily publishing a website’s files and configuration settings from the development machines to the final deployed site

·         Full support for Silverlight for developers wishing to build cutting-edge, rich internet applications.

 

 

 

 

Democratising Application Lifecycle Management

Microsoft Visual Studio Team System 2010 will deliver new capabilities that embrace the needs of the users in the lifecycle – from architects to developers, from project managers to testers. Among the great new functionality in Visual Studio Team System 2010:

·         Discover and identify existing code assets and architecture with the new Architecture Explorer

·         Design and share multiple diagram types, including use case, activity and sequence diagrams

·         Improve testing efforts with tooling for better documentation of test scenarios and more thorough collection of test data

·         Easily identify and run only the tests affected by a code change with the new Test Impact View

·         Enhanced version control capabilities including gated check-in, branch visualisation and build workflow.

 

 

 

 

Inspiring Developer Delight

Since the first release of Visual Studio, Microsoft has made application development more productive, efficient, flexible and profitable to the developers and companies that use it. Visual Studio 2010 continues to deliver on the core developer experience by significantly improving the day-to-day process for development teams:

·         Understand existing (and write new) code

·         Intuitive web development from the back-end to the end result

·         Wrangle disparate C++ code into one arena

·         Build new Windows 7 applications or upgrade existing applications

·         Enable Office tools to make your solutions more flexible and productive for specific needs.

 

 

Resource –

 

http://download.microsoft.com/download/C/0/9/C0965791-049B-4200-9008-F07A783026F6/VisualStudio2010_ProductOverview.pdf

April 17, 2009 Posted by vinayhatwal | VS-2010 | , , | No Comments Yet

.Net Framework 4.0

.Net Framework 4.0

 Every year the industry develops new technology and new trends. Now Microsoft is again come to provide next version of .net framework i.e. .Net Framework 4.0. As a result MS Visual Studio 2010 is just around the corner with the new innovation in application architecture, development, and deployment. So in this article I am describing some new features coming in the .Net Framework 4.0. Before describing new features of .Net Framework 4.0, I am giving a summary of some of the main functionality in each .net version. 

 

 

.NET Framework 4.0

(The Future Release)

PLINQ

TPL

.NET Framework 3.5

LINQ

ADO.NET Entity Framework

.NET Framework 3.0

WPF

WCF

WF

Card Space

.NET Framework 2.0

WinForms

ASP.NET

ADO.NET

Base Class Library

CLR

 

So you have just seen the major change in each version on .Net Framework. Above figure defines the feature stack of the .Net Framework.  

Following are new features provided by .NET Framework 4.0 – 

  • New Languages 

.NET 4.0 will include IronPython, IronRuby, and F#, among others. The three named languages have been available in some form for a few years now, but it appears that with .NET 4.0 they become “official” in the same way as C#, Visual Basic .NET. Both IronPython and IronRuby leverage the Dynamic Language Runtime (DLR), a subsystem that supports dynamic languages on .NET. The DLR has been around for a couple of years now, but with .NET 4.0 becomes an integral part of the .NET runtime. 

In order to support the new languages, and to ensure language interoperability, the CLR team did make some changes. Two additions are particularly interesting to me: BigInteger and Tuple. Because these features are in the base class libraries, all .NET languages can use them 

  • Threading improvements 

Framework 4.0 includes the Task Parallel Library (TPL), a library of objects that make it easier to write code that takes advantage of multiple cores. Not only do TPL functions relieve you of the tedium involved with starting and managing threads, they also help you to structure your code to make the most of the computing resources available. 

During development and use of the TPL, the CLR team found a number of areas in which the .NET thread pool (the subsystem that the TPL depends on) was less than optimum. They have since improved the thread pool, giving a performance boost not only TPL programs, but to all programs that make use of .NET threading services.  

  • Garbage Collector Improvements 

All in all, the .NET garbage collector is considered a good thing. However, it does have some drawbacks. In particular, it can severely impact performance in some cases.

The server garbage collector in .NET 3.51 and earlier versions is optimized for higher throughput, but has to pause all threads when it does a full collection. The result is that processing comes to a halt whenever a full collection occurs. This can be very annoying. 

The pauses still occur in .NET 4.0, but the system will notify your program before a full collection starts, and notify it again when the garbage collector has finished with collection. In a multi-server environment, you can use this feature to direct traffic away from your server while it’s in the middle of a full collection. That helps with server farms, but doesn’t help with memory-intensive applications that are running on a single machine. 

The workstation garbage collector in 4.0 gets a new background collection feature, which results in fewer pauses and doesn’t require any changes to your code. Only very unusual circumstances will result in the long latency that you might have seen in versions 3.51 or earlier 

  • PLINQ 

.Net Framework 3.5 introduced new concept i.e. LINQ(Language Integrated Queries). Microsoft original motivation behind LINQ was to address the impedance mismatch between programming languages and database 

Microsoft LINQ defines a set of proprietary query operators that can be used to query, project and filter data in arrays, enumerable classes, XML (XLINQ), relational database, and third party data sources. While it allows any data source to be queried, it requires that the data be encapsulated as objects. So, if the data source does not natively store data as objects, the data must be mapped to the object domain. Queries written using the query operators are executed either by the LINQ query processing engine or, via an extension mechanism, handed over to LINQ providers which either implement a separate query processing engine or translate to a different format to be executed on a separate data store (such as on a database server as SQL queries (DLINQ)). The results of a query are returned as a collection of in-memory objects that can be enumerated using a standard iterator function such as C#’s foreach. 

Like all constructs in LINQ, PLINQ is based on extension methods, in this case the AsParallel method. Once you’ve built the expression tree representing the query, the AsParallel operation is added at the very end, which tells the “LINQ engine” to figure out parallel jobs and do all of the magic required to make the app benefit from multi-threaded execution. A conceptual example is shown below: 

var result = (from p in db.Products join pd in xml.ProductDescriptions on p.ID equals pd.ID where p.Price > 100 select new { p.Name, p.Price, pd.Description }).AsParallel(); 

April 17, 2009 Posted by vinayhatwal | .Net Framework 4.0 | , , , , | No Comments Yet

Windows Services

Windows Services

By: Vinay Hatwal

Dated: Apr 10, 2009

Level: Beginner

 

The idea of using Windows services came into my mind when I was working on Finger Print Attendance System for Bajaj Capital Ltd. This system was going to be used by all the branches of the company. So I wanted to synchronize the attendance of the employees of each branch with our company’s ERP system. So that, I decided to develop windows services for the same purpose. There was one issue in real time synchronization of attendance with the Head Office. The issue was slow internet connection and no internet connectivity available all the time. So the solution was to send the attendance when internet is connected not on the time of attendance punching. So the solution was WINDOWS SERVICES.

In this article I will explain how to make Windows Services by using c#.net.

Windows services are long running executable file developed for running in background as long a windows is running. These executables run in the background and there is no any requirement for the user interaction. They run in the background so that there is no need to take graphical interface in the Windows Services. You can think about UNIX Daemon if u r familiar with the UNIX environment. On the Windows the same concept is Windows Services. Windows Services can be configured to run automatically when Windows is booted. They can also be configured to run on Local machine, single user account, and also on Network.

You can find windows services in your local machine on

Start-> Control Panel -> Administrative Tools -> Services

These services looks like this—

Windows Service Browser

Windows Service Browser

 

By using windows service you can use databases, text files, and all shareable resources with it etc.

To create Windows Services in .net (I am creating in .net 2.0)

Creating Windows Services

<!–[if !supportLists]–>1) <!–[endif]–>To create windows services, go to File menu and then select New Project, then select Windows Service. You will see the dialog box shown below. Name the project – MyWindowService.

12

2) After clicking on OK you will see the following. Change the name of the service from Service1.cs to MyService.cs.

2

3) Now go to in on the properties on the MyService and change the property Service Name to MyService.

 

 

4) Do right click on the MyService design view and select View Code option from the context menu. You can see two overrided methods in the window OnStart() and OnStop().

 

 

These are the members of the ServiceBase class and inheritted by the MyService Class. There are some more members also present in the ServiceBase class like OnContinue(), OnPause() etc. but I am just describing about these two only.

 

The idea of using windows service is only behind these to methods. Any work u want to perform on the sharable resources, you can write code for that in the OnStart() method. I have just put Beep () here. It will give the beep sound on starting the Window Service. And just 2 beep on Stoping it. You can see in the coding below.

3

<!–[if !supportLists]–>5) <!–[endif]–>to install this Windows Service on the local system you need to add installers in your Service. Just right click on the Service Design window and then select Add Installer.

<!–[if !supportLists]–>6) <!–[endif]–>Project Installer will automatically be added in your solution, name ProjectInstaller.sc. and you can also find two component in it

<!–[if !supportLists]–>a. <!–[endif]–>serviceProcessInstaller1

<!–[if !supportLists]–>b. <!–[endif]–>serviceInstaller1

 

 

<!–[if !supportLists]–>7) <!–[endif]–>You can now decide how your Windows Process will be display, you can set the account for your service on which it will be running, and you can give the Display Service Name, Description and the start type of the service like Automat, Manual, or Disabled. For doing all these you can follow these steps

<!–[if !supportLists]–>a. <!–[endif]–>Go to on the properties of serviceProcessInstaller1, and set Account property to Local System, so that it would be sharable to all users.

<!–[if !supportLists]–>b. <!–[endif]–>Now go to on the properties of serviceInstaller1, and ser Description as u like and set Display Name as u want to display in the Services Console, and now set StartType to Automatic so that the service can be run on the starting of the Windows operation system.

 

<!–[if !supportLists]–> 8) <!–[endif]–>After doing all the configuration just press F6 for building the solution. Now Your Window Service is ready to use.

 

<!–[if !supportLists]–>9) <!–[endif]–>Now for using it u have to install this service on your local machine. You can do this by using the instalUtill.exe utility provided by .net framework to install this service on your machine.

 

Now take the executable of this service and jus copy it into your system32 directory.

 

Go to your application path where your project is running, and go to the bin\debug directory then copy MyWindowServices.exe and paste it into syetem32.

 

 

Now go to on the Visual Studio 2005 Command Prompt and type the following for installing the newly developed Window Service–

 

C:\> installutil c:\windows\system32\ MyWindowServices.exe

4

To uninstall use –

 

C:\> installutil /u c:\windows\system32\ MyWindowServices.exe

 

 

You can see your service in the service console like

5

Now just do right click on it and the start. You will listen one beep on starting and two beep on stopping the Windows Service.

 

So friends. Enjoy the Window Services, hope your will learn by this article. Hope you will be enjoying after creation the windows service.

 

I am always waiting for your comments and suggestion so that I can improve my articles.

 

Again Coming Soon…………………….

 

 

 

Vinay Hatwal

April 10, 2009 Posted by vinayhatwal | Windows Services | , , , | No Comments Yet

 

NEW Features in Internet Explorer 8 beta

 

Ø     New to Beta 2! InPrivate

Ø     New to Beta 2!Delete Browsing History

Ø     Search

Ø     New to Beta 2!Search Suggestions

Ø     New to Beta 2! UserPreference Protection

Ø     New to Beta 2! CaretBrowsing

Ø     Accelerators(previously known as Activities)

Ø     Web Slices

Ø     New to Beta 2!Suggested Sites

Ø     Favorites Bar

Ø     New to Beta 2! TabGrouping

Ø     Automatic CrashRecovery

Ø     SmartScreen Filter (previouslyknown as the Phishing Filter)


New to Beta 2! InPrivate

When using the Internet for such activities as checking e-mail on afriend’s computer or shopping for a gift on a family PC, some users prefer notto leave any traces of their session. The InPrivateBrowsing feature of Internet Explorer 8 prevents the browser from savingsession history, temporary Internet files, form data, cookies, and usernamesand passwords.

ctivate InPrivateBrowsing by selecting Start InPrivate Browsing either from a New Tab page or from the Safety menu—which is new in Internet Explorer 8. With the featureactivated, Internet Explorer 8 will launch a session that will retain noinformation and leave no trace of the user’s browsing activity. By default,activation of InPrivate Browsing also activates InPrivate Blocking (discussed in the next section). Simplyclosing the browser window will end the InPrivatesession.

 

DeleteBrowsing History

Introduced in Internet Explorer 7, the Delete BrowsingHistory feature enables a single-click deletion of the datasaved by Internet Explorer. Deleting records of web browsing activity has neverbeen easier!

Not all such records, however, need to be deleted. Forfrequently visited websites, the information stored in cookies is especiallyuseful. While many websites offer the so-called “Remember me” option,others (for example, financial websites) will store a cookie on every computerfrom which a user has accessed them; one use of this would be to eliminate therequirement for challenge questions (e.g. “What was your high schoolmascot?”)

Internet Explorer 8 addresses this issue by allowing users topreserve the cookies and temporary Internet files from the websites added tothe Favorites list

Thus, to stay registered with a specific website, a user wouldsimply add the website’s URL to Favorites, making sure that Preserve Favoriteswebsite data is selected; Internet Explorer will preserve all cookies and cachefiles for the website.

However, if a user wants to erase the browsing history completely,the Delete Browsing History on Exit feature will do the job!

Search

The search functionality of Internet Explorer 8 builds upon thework we started in Internet Explorer 7, which saw the introduction of a searchbox that supports the addition of search providers through OpenSearchdescription files. We have enhanced the search box in Internet Explorer 8,adding features that will help users initiate a better search query and easilyswitch to a secondary search provider.

The main modification we have made in search is an improvedsearch box drop-down which will help users execute better queries. The InternetExplorer 8 search box drop-down includes AutoComplete, Search suggestions andresults from local history. AutoComplete results, which were available inInternet Explorer 7, show users queries that they had previously typed in thesearch box. Search Suggestions allow your currently selected search provider tosuggest different queries to you as you are typing in the search box. (Theseare discussed in detail in the section below.) Finally history results show theuser pages they had previously browsed to which are related to what they arecurrently typing in the search box.

SearchSuggestions

Search suggestionsallow a search provider to suggest different queries while a user is typingtext into the search box. Search suggestions, as they are implemented incurrent toolbars and competing browsers, consist mainly of text suggestions forrelated terms that users might want to find; in some cases, specific links arealso suggested.

CaretBrowsing

Caret Browsing is anew Accessibility feature that allows users to navigate a webpage using amoveable cursor on the screen and the keyboard. Users can select and copy textdown to a single character using only the keyboard. Other content types, liketable or images, can also be selected and copied.

Moving the cursorwithin the text of a webpage is similar to moving the cursor within the text ofa Word document. Holding the shift key down and pressing the arrow keys selectstext. Pressing F7 turns Caret Browsing on or off. It can be enabled on a pertab basis or for all tabs and windows.

Accelerators

Accelerators are acontextual feature used to quickly access a service from any webpage. It iscommon for users to copy and paste content from one webpage to another, andaccelerators simplify this process.

Accelerators allowusers to find information without leaving the current webpage. For example, todetermine the location of a specific restaurant, a user will select therestaurant’s address, generating an in-place view of the map. Clicking the viewwill open a full webpage that includes additional information from the mappingservice.

WebSlices

Web Slices is a new featurethat allows users to connect to a website by subscribing to content directlywithin a webpage on that website. Web Slices behave just like feeds, whereusers can subscribe to get updates and notifications of changes.

Internet Explorer 8users discover Web Slices within a webpage and add them to the Favorites bar: arow located below the Address bar and dedicated to easy access of links. Once auser has subscribed to a webpage, the browser will detect changes in the WebSlice and get notified about updates. Users can preview these updates directlyfrom the Favorites bar, and click through to the website to get moreinformation.

SuggestedSites

Suggested Sites is anew feature which helps you find new websites that are interesting and relevantto you. With your permission, Internet Explorer will suggest new websites basedon sites you have visited in the past. You can see these suggestions by openingthe Suggested Sites Web Slice…

or by visiting theSuggested Sites page from the Internet Explorer Favorites Center.

 

FavoritesBar

In Internet Explorer7, the Links bar provided users with one-click access to their favorite sites.This bar has undergone a complete renovation for Internet Explorer 8.Specifically, it has been renamed Favorites, and it will allow users to accessnot only their favorite web content, such as links, feeds and Web Slices, butalso the documents created in Microsoft Word, Excel, and PowerPoint.

By using the new Addto Favorites Bar command, which is conveniently located on the Favorites baritself, a user can easily add a link to the Favorites bar

 

TabGrouping

This new feature ofInternet Explorer 8 Beta 2 allows users to put related tabs—the tabs thatoriginate from the same webpage—into groups. Users can form tab groups in one ofseveral ways, such as by opening a link from within a webpage in another tab,or by right-clicking a specific tab and clicking New Tab. If, for example, auser chooses to queue up several different search results, the related tabswill not only open next to the original search result page (as opposed to theend of the tab band) but will also be put all in one group represented by asolid color. Different colors for different browsing tasks—for example, aresearch project, an online shopping spree, or a set of news articles openedfrom the same newspaper website—allow users to quickly identify the tabs.

AutomaticCrash Recovery

The Automatic CrashRecovery (ACR) feature of Internet Explorer 8 helps to prevent the loss of workin the unlikely event of browser failure or nonresponse.ACR takes advantage of the Loosely Coupled feature of Internet Explorer toprovide new crash recovery capabilities, including tab recovery,that will minimize interruptions to a browsing session.

SmartScreen Filter

A phishingsite imitates a legitimate site to steal the user’s personal or financialinformation. In Internet Explorer 7, we introduced the PhishingFilter: a feature that warns users that they are about to visit a phishing site. For Internet Explorer 8, we have built uponthe success of the Phishing Filter—which blocks overa million phishing attacks weekly—to develop the SmartScreen Filter. The latter offers the followingenhancements:

·                   Improved userinterface

·                   Faster performance

·                   New heuristics andenhanced telemetry

·                   Anti-malware support for blocking unsafe downloads

·                   Improved group policysupport

 

 

References

 

October 26, 2008 Posted by vinayhatwal | Internet Explorer 8 beta | | No Comments Yet

PL/SQL Pragma

PL/SQL Pragma

 

Pragma –

Pragma is nothing but the compiler directive which simply conveys the information to the compiler. Because the Pragma is the complier directive so the processed at compile time not run time.

 

AUTONOMOUS_TRANSACTION Pragma

 

AUTONOMOUS_TRANSACTION Pragma instructs to the compiler to mark a transaction autonomous, or you can independent. An Autonomous transaction is the independent transactions which runs by the another transaction or main transaction. An autonomous transaction suspends the main transaction in which they are calling, do the SQL statements, commit or rollback then according to the user’s need then after completing resume the main transaction.

 

Commit or Rollback only works for the statements which are inside the calling transaction so that they are independent to the main transaction.  It does not share any lock, resources and any commit or rollback dependence with the main transaction.

 

If you are using it with the triggers then unlike normal triggers these autonomous triggers can perform the DDL operation by using the native dynamic SQL. If you set the isolation level of the main transaction to SERIALIZABLE, as follows, changes made by its autonomous transactions are not visible to the main transaction hen it resumes:

 

See, if the main transaction perform the rollback at any save point after the autonomous block then it will not effect the changes made by the autonomous transaction because the autonomous transaction is fully independent from it’s main transaction.

 

 

Limitations –

You can not use the Pragma in the Subprogram that resides in the package. You can only user Pragma in the individual subprogram. You can use Pragma anywhere in the declarative part of the PL/SQL Block but always use it on the top position in the declarative part for readability.

 

 

 

Consider the following block of code –

 

 

– Main Procedure (Caller Procedure)

create or replace procedure MainProc as

begin

 

    update myemployeemaster set employeename=‘vinny’ where employeename=‘Ashish’;

    SimpleProc;      – Calling an ordinary procedure

    rollback;

   

exception

when others then null;

end;

 

– Procedure without Autonomous Transaction Block (Calee Procedure)  

create or replace procedure SimpleProc as

begin

 

    update myemployeemaster set employeename=‘Vikram’ where employeename=‘Pawan Kumar’;

    commit;

   

exception

when others then null;

end;

 

 

 

Explanation-

 

In the above example the MainProc updates the MyEmployeeMaster table and update the name  Ashish to Vinny. But After a SimpleProc call the procedure want to rollback his transaction. But when the SimpleProc procedure called the control of MaiProc goes into the SiimpleProc. In the SimpleProc MyEmployeeMaster is again updating the name Pawan Kumar with the name Vikram and then it commit its transactions. After the completing of SimpleProc the control again goes to the MainProc Procedure and then want to rollback all the changes done by it. But See, The SimpleProc Transaction has already committed the whole transactions. See the effect in the table MyEmployeeMaster, You will see that all the transactions are committed even of the MainProc Procedure.

It happened because the in the both procedure only single transaction is working, both are the part of a single transaction. So If you want to work on different Procedure for different transactions then you can use the Autonomous_Transaction Pragma. This Pragma will direct to the compiler for doing the different Transaction for the block where it defined.

 

Now the following Block of code is modified by using Autonomous_Transaction Pragma –

 

 

– Main Procedure (Caller Procedure)

create or replace procedure MainProc as

begin

 

    update myemployeemaster set employeename=‘Vinay’ where employeename=‘Vikram’;

    AutoProc;      – Calling an ordinary procedure

    rollback;

   

exception

when others then null;

end;

 

– Procedure without Autonomous Transaction Block (Calee Procedure)  

create or replace procedure AutoProc as

pragma autonomous_transaction;

begin

 

    update myemployeemaster set employeename=‘Pawan Kumar’ where employeename=‘vinny’;

    commit;

   

exception

when others then null;

end;

 

 

 

Explanation-

Now consider the about block of code. In this code AutoProc Procedure difines the Pragma Autonomous_Transaction. So that it has a different transaction for this procedure . When a Commit operation is performed then it will only commit those transactions which are rekated to this procedure. And when the control goes back to the MainProc then it will rollback the transactions of the MainProc Procedure. So As a result name vinny in the MyEmployeeMaster is changed with the name Pawan Kumar. But  Vikram has not changed with the Vinay.

August 25, 2008 Posted by vinayhatwal | PL/SQL Pragma | , , | No Comments Yet

Oracle Cursors

ORACLE CURSORS

 

 

Cursors are the work place user by the Oracle engine for its internal processing to save the data returned by the SQL statements. The type of a cursor depends upon the nature of its working. For Example if Oracle Engine open a cursor for its internal processing then it is known as Implicit Cursor and is a cursor defined by the user as a user defined cursor then it is called as Explicit Cursor.

 

 

Implicit Cursors

 

Implicit Cursors are automatically used by the Oracle Engine to store some information regarding the internal processing of the server. Implicit Cursors are automatically created, fetches records and closed by the oracle database server.

 

Basically Internal Cursors are used to table the information about last insert, update, delete or single row select statement.

 

Implicit Cursor Attributes

 

1)       SQL%ISOPEN If the cursor is open then this attribute returns TRUE otherwise returns FALSE. In the case of implicit cursors this attribute always return FALSE because Implicit Cursors are automatically open and the closed by the Oracle Engine.

 

2)       SQL%FOUND – If cursor affects one or more then one row by the SQL statement then this attribute will return TRUE otherwise it will return FALSE.

 

3)       SQL%NOTFOUND – This is opposite to the SQL%FOUND attribute. If the statement will not return any of the value then this attribute will be TRUE otherwise it will by FALSE.

 

4)       SQL%ROWCOUNT – You can count number of affected rows by the last SQL statement by using this attribute.

 

Consider the following block of code-

 

Take the table used in the tutorial Native Dynamic SQL (MyEmployeeMaster).

 

 

CREATE OR REPLACE PROCEDURE demo_imp IS

 row_deleted VARCHAR2(30);

BEGIN

  

        update MYEMPLOYEEMASTER set EMPLOYEENAME=‘Ashish’ where upper(EMPLOYEENAME) like ‘%V%’;

       

       

        IF SQL%ISOPEN THEN

            dbms_output.put_line(‘SQL%FOUND – True’);

        else

            dbms_output.put_line(‘SQL%FOUND – False’);

        END IF;

 

 

        IF SQL%FOUND THEN

            dbms_output.put_line(‘SQL%FOUND – True’);

        else

            dbms_output.put_line(‘SQL%FOUND – False’);

        END IF;

              

            

        IF SQL%NOTFOUND THEN

            dbms_output.put_line(‘SQL%NOTFOUND – True’);

        else

            dbms_output.put_line(‘SQL%NOTFOUND – False’);

        END IF;

         

        dbms_output.put_line(‘SQL%ROWCOUNT – ‘ || SQL%ROWCOUNT || ‘ NO OF ROWS AFFACTED’);

       

END demo_imp;

 

 

 

 

Resule of above procedure –

 

SQL> set serverout on;

SQL>  exec demo_imp;

SQL%FOUND – False

SQL%FOUND – True

SQL%NOTFOUND – False

SQL%ROWCOUNT – 3 NO OF ROWS AFFACTED

 

Explicit Cursors –

 

Explicit Cursors are explicitly used by the user for the data processing. Explicit Cursors are not automatically opens and close by like an Implicit Cursor. It is declare, open and close by the user in the PL/SQL block. Following are the steps to take by the user for using the Explicit Cursors in their PL/SQL block.

 

1)              Declare the cursor in the declaration section with CURSOR keyword.

2)              Open the declared Cursor by using the OPEN keyword.

3)              Fetch the Record from the opened cursor by the FETCH … INTO keywords.

4)              Process the data in the cursor by using the loop by using the LOOP…. END LOOP block.

5)              Fetch the next record and point out the pointer to the next record by using the FETCH…. INTO.

6)             

Close the opened cursor by using the CLOSE keyword.
 
 

 

Explicit Cursor Attributes-

               

1)   SQL%ISOPEN If the cursor is open then this attribute returns TRUE otherwise returns FALSE.

 

2)   SQL%FOUND – If cursor affects one or more then one row by the SQL statement then this attribute will return TRUE otherwise it will return FALSE.

 

3)   SQL%NOTFOUND – This is opposite to the SQL%FOUND attribute. If the statement will not return any of the value then this attribute will be TRUE otherwise it will by FALSE.

 

4)   SQL%ROWCOUNT – You can count number of affected rows by the last SQL statement by using this attribute.

 

Consider the following block of code

 

 

CREATE OR REPLACE PROCEDURE demo_exp IS

 

 cur sys_refcursor;  

 employeeidx number;

 eployeenamex varchar2(20);

BEGIN

  

    open cur for select employeeid, employeename from myemployeemaster;

    fetch cur into employeeidx,eployeenamex ; 

    while cur%found

    loop

        dbms_output.put_line(‘employeeid: ‘ || employeeidx  || ‘—-’ || ‘eployeename: ‘ || eployeenamex );

        fetch cur into employeeidx,eployeenamex ; 

        commit;

    end loop;   

END demo_imp;      

 

<p class=”MsoNormal” style=”text-align:justify;margin:0;”

August 19, 2008 Posted by vinayhatwal | Oracle Cursors | , , , , | No Comments Yet

Native Dynamic SQL

Native Dynamic SQL

 

Hello friends,

I am again come with new tutorial, Native Dynamic SQL. In this tutorial we will learn –

 

1)   What is Native Dynamic SQL

2)   How it can be used in PL/SQL

3)   Benefits of the Native Dynamic SQL.

 

What is Native Dynamic SQL?

 

Native dynamic SQL is the mechanism where you can dynamically perform the operation on the oracle database schemas. Native dynamic SQL makes your program more flexible in such situations where you don’t know any information about what to do, in advance. Consider the situation where a reporting tool maintain data on daily basis and there are a lot of source table which contain the data on the basis of some parameters and these parameters can also be changed at run time. So what you will do in this situation. Native Dynamic SQL can be used to handle this type of situation.

 

Native Dynamic SQL statement can be built same as a string variable. And also the bind variables can be used with them to improve the performance of the operations. Remember when you perform any of the operation with PL/SQL, PL/SQL automatically convert the variables of the statement to the bind variable to improve the performance of the statement. When you build up such statements with the Native Dynamic SQL then you have to specify the bind variables with the statement, however it is not mandatory. If you will not give the bind variable, PL/SQL will automatically convert them into bind variables but it will give more overhead on the Server.  

 

So, The Native Dynamic SQL statements can be generated at the run time (dynamically).

 

How it can be used in PL/SQL

 

Native Dynamic SQL statements can be executed by using EXECUTE IMMEDIATE statement following by the single quoted varchar variable with SQL statement.

 

 

DECLARE

   str VARCHAR2 (4000);

BEGIN

   str:= ‘DELETE FROM STUDENT_MASTER WHERE STUDENT_ID=1′;

   EXECUTE IMMEDIATE str;

EXCEPTION

   WHEN OTHERS THEN

      NULL;

END;

 

Above example just delete the student with student id =1.

You can also use bind variable with the Native Dynamic SQL for improving the performance of the direct SQL statements.

 

 

Benefits of the Native Dynamic SQL

1)   You can use DDL (CREATE TABLE, DROP TABLE, ALTER TABLE etc) statements and DCL Statements with the PL/SQL block. In PL/SQL these statement can’t be executed statically.

 

2)   By using Native Dynamic SQL statements you can create the SQL statements with using different WHERE clause conditions in a SELECT statement.

 

 

EXECUTE IMMEDIATE The Magic statement to execute Dynamic SQL

 

EXECUTE IMMEDIATE is the statement for executing the SQL statements dynamically in the PL/SQL block or even for executing the PL/SQL block itself.

 

Syntax of Execute immediate -

 

EXECUTE IMMEDIATE dynamic_string

[INTO {define_variable[, define_variable]… | record}]

[USING [IN | OUT | IN OUT] bind_argument

[, [IN | OUT | IN OUT] bind_argument]…]

[{RETURNING | RETURN} INTO bind_argument[, bind_argument]…];

 

Brief Explanation –

 

EXECUTE IMMEDIATE is used to dynamically execute the SQL statement where dynamic_string is the string type variable which contains the Dynamic SQL. INTO clause is used to take the selected values form the query into the defined variables and record is the %ROWTYPE or user defined records. USING clause is used to take IN or OUT bind variables. RETURNING INTO clause is used with the DML statements which have the RETURNING clause with them for returning the affected column value.

 

Consider the following example –

 

CREATE OR REPLACE procedure WEALTHMAKER.MyTest as 

sql1 varchar(4000);

myrefcur sys_refcursor;

employeecodex number;

employeenamex varchar2(20);

salarymonthx varchar2(20);

salaryyearx varchar2(20);

salaryx varchar2(20);

salaryy number;

TYPE RefEmpTyp IS REF CURSOR;

cv RefEmpTyp;

begin

 

    /***************************************************************************************

                                                BLOCK1   -    DCL STATEMENT

   

    ***************************************************************************************/

    – Droping table if exists

    begin

    execute immediate ‘drop table MyEmployeeMaster’;

    exception

        when others then

        null;

    end;

   

    – Droping table if exists

    begin

    execute immediate ‘drop table MyEmployeeSalary’;

    exception

        when others then

        null;

    end;

   

    – Droping view if exists

     begin

    execute immediate ‘drop view MyClientView’;

    exception

        when others then

        null;

    end;

       

    – Creating a master table

    begin

    execute immediate ‘create table MyEmployeeMaster(EmployeeId number,EmployeeName varchar2(20))’;

    exception

        when others then

        null;

    end;

   

    – Creating Detailed Table

    begin

   

    execute immediate ‘create table MyEmployeeSalary(EmployeeId number,Salary varchar2(20),SalaryMonth number,SalaryYear number)’;

    exception

        when others then

        null;

    end;

   

    /******************************************************************************************

                                                BLOCK2  -    DML STATEMENT

   

    ******************************************************************************************/

    – Inserting values in Master Table

    execute immediate ‘insert into MyEmployeeMaster values (1,”Vinay Hatwal”)’;

    execute immediate ‘insert into MyEmployeeMaster values (2,”Piyush Aggrawal”)’;

    execute immediate ‘insert into MyEmployeeMaster values (3,”Vinita Sharma”)’;

    execute immediate ‘insert into MyEmployeeMaster values (4,”Varsha Dhiman”)’;

    execute immediate ‘insert into MyEmployeeMaster values (5,”Pawan Kumar”)’;

   

   

    – Inserting Values in Detailed Table

    execute immediate ‘insert into MyEmployeeSalary values (1,2000,2,2008)’;

    execute immediate ‘insert into MyEmployeeSalary values (1,2000,3,2008)’;

    execute immediate ‘insert into MyEmployeeSalary values (1,2000,4,2008)’;

    execute immediate ‘insert into MyEmployeeSalary values (1,2000,5,2008)’;

    execute immediate ‘insert into MyEmployeeSalary values (2,2000,2,2008)’;

    execute immediate ‘insert into MyEmployeeSalary values (2,2000,3,2008)’;

    execute immediate ‘insert into MyEmployeeSalary values (2,2000,4,2008)’;

    execute immediate ‘insert into MyEmployeeSalary values (2,2000,5,2008)’;

    execute immediate ‘insert into MyEmployeeSalary values (3,2000,2,2008)’;

    execute immediate ‘insert into MyEmployeeSalary values (3,2000,4,2008)’;

  

    commit;

   

   

    /******************************************************************************************

                                                BLOCK3   -    QUERY 

   

    ******************************************************************************************/

    – Creating View for Displaying

    SQL1:= ‘ create or replace view MyClientView as  ;

    SQL1:= SQL1 || ’select m.EmployeeId,m.EmployeeName,s.SALARYMONTH,s.SALARYYEAR,s.SALARY from MyEmployeeSalary s, MyEmployeeMaster m  ;

    SQL1:= SQL1 || ‘where s.EmployeeId(+)=m.EmployeeId and (s.salarymonth=”02” or s.salarymonth is null)  ;

       

    execute immediate sql1;

 

    open cv for ’select * from MyClientView’;

    loop

        fetch cv into employeecodex,employeenamex,salarymonthx,salaryyearx,salaryx;

        EXIT WHEN cv%NOTFOUND;

        dbms_output.PUT_line(employeecodex ||      || employeenamex  ||      || salarymonthx   ||      || salaryyearx   ||      || salaryx);

    end loop;

   

   

    /******************************************************************************************

                                     BLOCK4  -    DML STATEMENT WITH RETURNING INTO VLAUSE

   

    ******************************************************************************************/

    execute immediate ‘update MyEmployeeSalary set salary=50000 where employeeid=1 and salarymonth=2 and salaryyear=2008 returning salary into :2′ returning into salaryy;

    commit;

        dbms_output.PUT_line();

        dbms_output.PUT_line();

        dbms_output.PUT_line(‘Updated Salary—-’ || salaryy);

   

   

    open cv for ’select * from MyClientView’;

    loop

        fetch cv into employeecodex,employeenamex,salarymonthx,salaryyearx,salaryx;

        EXIT WHEN cv%NOTFOUND;

        dbms_output.PUT_line(employeecodex ||      || employeenamex  ||      || salarymonthx   ||      || salaryyearx   ||      || salaryx);

    end loop;

   

exception

    when others then

    dbms_output.put_line(SQLERRM(SQLCODE));

end;

 

 

Brief Explanation –

 

BLOCK 1 – Specifies the DDL statement, some Tables are dropped and Some Tables are created with using the dynamic SQL.

 

BLOCK 2 – Specifies some DML statements which insert values into the table created in the BLOCK 1.

 

BLOCK 3 – View is created to show the data at the run time by using the Implicit Cursor for the Query.

 

BLOCK 4 – Specifies DML statement UPDATE to show the working of RETURNING INTO clause with the EXECUTE IMMEDIATE.

 

 

USING Vs. RETURNING INTO

 

By using OUT parameter with USING clause you can also take the advantage of the RETURNING INTO clause.

Consider the following block of code –

 

 

 

 

CREATE OR REPLACE procedure WEALTHMAKER.UsingVsRETINTO as 

str varchar2(4000);

bsalary number;

bsalary_out number;

bemployeeid number;

bmonth number;

byear number;

begin

 

    bsalary:=40000;

    bemployeeid:=1;

    bmonth:=2;

    byear:=2008;

   

    str:= ‘ update myemployeesalary set salary=:bind_salary where employeeid=:bind_employeeid  ;

    str:= str ||     and salarymonth=:bind_month and salaryyear=:bind_year returning salary into :bindsalaryret ‘;

 

    –Statement 1

    execute immediate str using bsalary,bemployeeid,bmonth,byear,out bsalary_out;

    dbms_output.put_line(bsalary_out);

   

   

    bsalary:=50000;

    –Statement 1

    execute immediate str using bsalary,bemployeeid,bmonth,byear returning into  bsalary_out;

    dbms_output.put_line(bsalary_out);   

 

exception

    when others then

    dbms_output.put_line(SQLERRM(SQLCODE));

end;

 

 

In the above example you can see in Statement 1, the updated salary is taken out into bsalary_out OUT parameter by using the USING clause

 

But in the case of Statement 2, updated salary is taken out by using the RETURNING INTO clause.

 

So, finally you can use any of the statement to return the result of the DML statement.

 

The only difference in these two statements is, with USING clause all the followed parameter are IN mode by default, it means you need not to specify the IN mode for the variable, On the other hand in the case of RETURNING INTO clause all the variables are in the OUT mode by default.

 

 

Using Schema Name with Dynamic SQL

 

Suppose you want to user the Scheme name with the Dynamic SQL then normally you might write the code like the following –

 

CREATE PROCEDURE drop_some_table (tablename IN VARCHAR2) AS

BEGIN

EXECUTE IMMEDIATE ‘DROP TABLE :tab’ USING table_name;

END;

 

But Remember, you will find the error Invalid Table Name because you can’t use bind variables with any schema name. So you should write the following code to debug the above code.

 

CREATE PROCEDURE drop_some_table (tablename IN VARCHAR2) AS

BEGIN

EXECUTE IMMEDIATE ‘DROP TABLE ‘ || table_name;

END;

 

Duplicate Placeholders

 

Placeholders in Dynamic SQL are the elements by which the bind variables are associated with the corresponding item followed by the USING clause. These variables are associated with the values by the position not by the name. So remember the you can use the same name with the placeholders. For examples consider the following line of code:

 

sql_stmt := ’INSERT INTO payroll VALUES (:x, :x , :y, :x )’;

 

it does not matter you are writing the execute stament like this

 

EXECUTE IMMEDIATE sql_stmt USING a, a, b, a;

Or

EXECUTE IMMEDIATE sql_stmt USING a, b, b, a;

August 18, 2008 Posted by vinayhatwal | Native Dynamic SQL | , , , | No Comments Yet

Crystal Report With .Net

Crystal Report with C#.Net 2.0

 

Using Crystal Report is very easy task. Sometime we afraid to use crystal reports with the code of Vb.Net or C#.Net even when we have used crystal reports in the previous technologies like Visual Basic 6. Before writing this tutorial I found some of my friends unable to user crystal report and stuck out in small problems regarding Crystal Report. So I decided to write this tutorial for them and also for those people who are afraid with Crystal Reports and found some difficulties to use it. This tutorial may play a very important role to learn Crystal with Vb.Net/C#.Net for those are new to take crystal with .Net but have used crystal with some of the earlier technologies or who are new even to Crystal.

 

So Friends, Lets Have a look on the tools used in crystal reports with VB.Net/C#.Net.

 

1)      DataSet (System.Data.DataSet)

2)      Crystal Report

3)      CrystalReportViewer1 (CrystalDecisions.Windows.Forms.CrystalReportViewer)

4)      System.Data.SqlClient

 

Now Follow these Steps for the first stage to learn the crystal reports

 

Stage 1 Create Data Base Table (I ussed SqlServer2000)

 

1. Create These Basic Tables using SqlServer2000

 

Create Table DemoStudentMaster

(

            StudentId int primary key,

            StudentName varchar(15),

            StudentAddress varchar(50),

            StudentCity varchar(20),

            StudentMobile varchar(10)

)

 

Create Table StudentFeeDetails

(

            StudentId int references DemoStudentMaster(StudentId),

            SumittedFeeAmt int,

            ForMonth int,

            ForYear int

)

 

2. Insert Values in These Tables

 

DemoStudentMaster

insert into DemoStudentMaster values (1,’Vinay Hatwal’,'Nehru Place’,'New Delhi’,'9911884523′);

insert into DemoStudentMaster values (2,’Panjak Pundir’,'Nehru Place’,'New Delhi’,'7483434356′);

insert into DemoStudentMaster values (3,’Ashish C.’,'Nehru Place’,'New Delhi’,'7473949866′);

insert into DemoStudentMaster values (4,’Sandeep S.’,'Nehru Place’,'New Delhi’,'791198475′);

insert into DemoStudentMaster values (5,’Pradeep K.’,'Nehru Place’,'New Delhi’,'8911884523′);

 

StudentFeeDetails

 

insert into StudentFeeDetails values (1,1000,2,2008);

insert into StudentFeeDetails values (1,1000,3,2008);

insert into StudentFeeDetails values (1,1000,4,2008);

insert into StudentFeeDetails values (1,1000,5,2008);

insert into StudentFeeDetails values (1,1000,6,2008);

insert into StudentFeeDetails values (1,1000,7,2008);

 

 

insert into StudentFeeDetails values (2,4000,2,2008);

insert into StudentFeeDetails values (2,4000,3,2008);

insert into StudentFeeDetails values (2,4000,4,2008);

insert into StudentFeeDetails values (2,4000,5,2008);

insert into StudentFeeDetails values (2,4000,6,2008);

 

 

insert into StudentFeeDetails values (3,3000,2,2008);

insert into StudentFeeDetails values (3,3000,3,2008);

insert into StudentFeeDetails values (3,3000,4,2008);

 

 

insert into StudentFeeDetails values (5,10000,2,2008);

insert into StudentFeeDetails values (5,10000,3,2008);

 

 

Now Your Tables Are Ready To Use in Crystal Report.

 

Stage 2 – Creating Sample Application in .Net

 

  1. Using C#.Net 2.0

 

 

 

a)      Open a new Project with C# names MyDemoCrystalPrj.

 

b)      Open Solution Explorer , Right Click on MyDemoCrystalPrj then click on Add and then click on New Items.

 

c)      Now Select The DataSet. Renamed it as SampleDataSet , Click on Add Button. Now The SampleDataSet.xsd tab will display.

 

 

   d) Right click on the middle of the page and then click on Add and then DataTable, After Clicking on it a Data Table will Appear on screen.

 

 

e)      Now Right Click on DataTable1 and select Rename . Rename id as StudentMasterTable.

f)      After it Right Click on The table and Select Add then Column. Make The Following Column in it.

a.       StudentID

b.      StudentName

c.       StudentAddress

d.      StuentMob

 

g)      Now Again Open Solution Explorer , Right Click on MyDemoCrystalPrj then click on Add and then click on New Items then select Crystal Report. Rename it as MasterCrystalReport.rpt(All the related references will be automatically added in the references)

h)      After Adding Crystal In Project Following Dialog Box Will appear on the screen

 

 

 

 

i)      Select option As a Blank Report and then press OK. Crystal Report will appear and looks like

 

 

j)      Now right click on DataBase Fields in the Field Explorer , Select Database Expert. After selecting it following screen will appear.

      Select Project Data > ADO.NET DataSets > MyDemoCrystalPrj.SampleDataSet

then add it and then click on OK

 

k)      Now Field Explorer will look like

 

l)      Drag then Fields of StudentMasterTable in the detail section of the Crystal Report. You Can also take the heading on the Report Header Section .Right Client On Report Header Section , Select Insert then Select Text Object. Give the Text as Student Detail and format it according to your need. After Inserting all the things your report will look like

 

 

 

m)      Now Open Form1 and Take CrystalReportViewer Form the Crystal Report Strip in the Toolbox.

n)      Now Go To the Coding Window of  Form1 and write the following code.

 

using System;

using System.Collections.Generic;

using System.ComponentModel;

using System.Data;

using System.Data.SqlClient;

using System.Drawing;

using System.Text;

using System.Windows.Forms;

 

namespace MyDemoCrystalPrj

{

    public partial class Form1 : Form

    {

        SqlConnection con;

        DataSet ds;

        public Form1()

        {

            SqlDataAdapter adp;

            con = new SqlConnection(“Server=.;Database=master;Integrated Security=true”);

            ds = new DataSet();

            adp = new SqlDataAdapter(“select StudentId,StudentName,StudentAddress,StudentCity,StudentMobile from DemoStudentMaster”, con);

            adp.Fill(ds, “StudentTable”);

            InitializeComponent();

        }

 

        private void Form1_Load(object sender, EventArgs e)

        {

            MasterCrystalReport cr = new MasterCrystalReport();

            cr.SetDataSource(ds.Tables["StudentTable"].DefaultView);

            crystalReportViewer1.ReportSource = cr;

            crystalReportViewer1.Show();

        }

    }

}

 

o)      Finally Run The Project. Your Crystal Report Will Look Like

 

Note – If you find the helps you for learning the crystal report as a beginner the please write comment on this tutorial or just writ few words on vinayhatwal@gmail.com. I will be back by taking some new tutorial on new technologies soon.

  

August 13, 2008 Posted by vinayhatwal | Crystal Report With .Net | | No Comments Yet