Jagadish's profileJagadish Pulakhandam'sPhotosBlogListsMore Tools Help

Jagadish Chatarji

Fastest path to upgrade to latest .NET technologies

Feed

The owner hasn't specified a feed for this module yet.
Blogs I mostly visit

Jagadish Pulakhandam's

Blogging on .NET, SQL Server and Oracle
October 13

TIP: How to fix readonly external hard disks to function in normal mode?

 
Intermittently, your external harddisk may turn to readonly mode.  I am talking about the harddisks which do not have any exclusive read-only switch/locks.  Even if you restart or plug-in to another computer, the readonly mode may not change.
 
To make it functioning in write mode as well, just do the following steps:
 
1.  Go to command prompt
2.  Type "DISKPART" and hit enter.  You will get "DISKPART>" prompt.
3.  type "SELECT VOLUME Z" at the "DISKPART" prompt ("Z" being the drive letter of the readonly external hard disk.  You need to provide your own drive letter here).  The command has to return with "Volumn 4 is the selected volume" (your volume number could be different) followed by DISKPART prompt.
4.  type "ATTRIBUTES VOLUME CLEAR READONLY" at the "DISKPART" prompt.  This would clear the "READONLY" attribute of the hard disk.  It has to return with the message "Volume attributes cleared succesfully".
5.  type "EXIT" at the "DISKPART" prompt to get back to normal prompt.
 
I managed to get the above working (twice) with 1.5TB Western Digital External Disk on Windows Server 2008.
 
thanks
Jag
 
February 04

Article: How to bind ComboBox and DataGrid controls in Silverlight 2.0

 
Hai,
 
My next article on Silverlight 2.0 focusing on "Binding ComboBox and DataGrid controls" got published here http://www.aspfree.com/c/a/BrainDump/Introduction-to-Binding-ComboBox-and-DataGrid-Controls-in-Silverlight-20/
 
Enjoy..
 
thanks
Jag
January 16

My first day with Windows 7 (beta)

 
Hai Everyone,
 
Yesterday, I was lucky enough to receive first version of "Windows 7 Beta" installed successfully on my machine.  Definitely, it is the most exciting "Windows" release ever.  It is almost impossible to cover all of its great features in one single post.  Let us see how it looks with default color scheme for the first time:
 
 
Let us see the first set of cool things which are eye catching:
 
 
 
 
 
 
 
 
 
 
 
 
 
More on next post.
 
thanks
Jag
January 15

Article: Designing WCF DataContract Classes Using "LINQ to SQL" Designer

 
Hai,
 
My new article on "Designing WCF Data Contract Classes using "LINQ to SQL" Designer" got published here.
 
thanks
Jag
December 13

Article: Database operations using Silverlight 2.0, WCF and LINQ to SQL

 
Hai,
 
My next article focusing on development using Silverlight 2.0, WCF and LINQ to SQL got published here http://www.aspfree.com/c/a/Windows-Scripting/Database-operations-using-Silverlight-20-WCF-and-LINQ-to-SQL/
 
Enjoy......
Jag
December 04

Article: LINQ to XML Programming using Visual Basic 2008

 
Hai,
 
My new article on "LINQ to XML programming using Visual Basic 2008" got published here http://www.aspfree.com/c/a/VB.NET/LINQ-to-XML-Programming-Using-Visual-BasicNET-2008/.
 
Another article on on "XML DOM programming using Visual Basic 2005" got published here http://www.aspfree.com/c/a/Windows-Scripting/Visual-Basic-2005-XML-Programming-Using-XML-DOM/
 
thanks
Jag
November 14

Article: Silverlight 2.0 application with "LINQ to SQL" and WCF Service

 
Hai,
 
My new article on "Silverlight 2.0 application development with 'LINQ to SQL' and WCF Service" got published here http://www.aspfree.com/c/a/Windows-Scripting/Silverlight-20-Application-Development-with-LINQ-to-SQL-and-a-WCF-Service/
 
thanks
Jag
November 07

Article: Creating a Silverlight 2.0 Application that Consumes a WCF Service

 
Hai,
 
My new article on "Silverlight 2.0 accessing WCF Service using Visual Studio 2008" got published here http://www.aspfree.com/c/a/Windows-Scripting/Creating-a-Silverlight-20-Application-that-Consumes-a-WCF-Service/
 
thanks
Jag
October 30

Article: Beginning Silverlight 2.0 development using Visual Studio 2008

 
Hai,
 
My new article on "Beginning Silverlight 2.0 development using Visual Studio 2008" got published here http://www.aspfree.com/c/a/BrainDump/Beginning-Silverlight-20-Development-using-Visual-Studio-2008/
 
thanks
Jag
October 10

Article: Understanding Delegates using Visual Basic.NET 2005

 
All,
 
My new article on "Delegates using Visual Basic 2005" got published here http://www.aspfree.com/c/a/VB.NET/Understanding-Delegates-using-Visual-BasicNET-2005/
 
It explains delegates in a simplest fashion.  If you are new to eventing in Visual Basic, make sure that you complete this http://www.aspfree.com/c/a/VB.NET/Understanding-Custom-Events-using-Visual-Basic-NET-2005/ before you go to delegates.
 
thanks
Jag
August 20

Beginning Sharepoint Web part development using Visual Studio 2008

 
Everyone,
 
My new article on "Sharepoint Web Part development using Visual Studio 2008" got published here:
 
 
This will be a great introduction to beginners who would like to learn developing web parts using WSS 3.0 (Windows Sharepoint Services) together with Visual Studio 2008.
 
It covers the following:
 
-> creating a new WSS test web site
-> creating a new WSS web part page
-> developing a simple web part using WSS 3.0 and Visual Studio 2008
-> Deploying and viewing the web part
-> Debugging the web part.
 
Hope you will enjoy reading it.
 
thanks
Jag
July 17

Tip: Generating iCalender file using ASP.NET

 
iCalender is something like an open format text file to add items to the calendar (like Outlook calendar).  It is simply a text file which contains fields and information about the particular event of a calendar.  Once you double click on the iCalendar file, the respective event gets registered in Outlook calendar (of course, with your approval for the event!).
 
Following is the ASP.NET code, which generates iCalendar file dynamically (on the fly) and pushes the same to user.  The user can either directly open it into Outlook or simply save the iCalendar file.
 

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

        Dim sb As New StringBuilder(215)

        sb.AppendFormat("BEGIN:VCALENDAR{0}", Environment.NewLine)

        sb.AppendFormat("CALSCALE:GREGORIAN{0}", Environment.NewLine)

        sb.AppendFormat("VERSION:1.0{0}", Environment.NewLine)

        sb.AppendFormat("BEGIN:VEVENT{0}", Environment.NewLine)

        sb.AppendFormat("DTSTART:20080703T093000{0}", Environment.NewLine)

        sb.AppendFormat("DTEND:20080703T113000{0}", Environment.NewLine)

        sb.AppendFormat("LOCATION:testing some location{0}", Environment.NewLine)

        sb.AppendFormat("SUMMARY:Testing Some subject{0}", Environment.NewLine)

        sb.AppendFormat("CLASS:PUBLIC{0}", Environment.NewLine)

        sb.AppendFormat("END:VEVENT{0}", Environment.NewLine)

        sb.AppendFormat("END:VCALENDAR{0}", Environment.NewLine)

 

        Dim enc As New UTF8Encoding

        Dim arrBytData() As Byte = enc.GetBytes(sb.ToString)

 

        Response.Clear()

        Response.ContentType = "text/plain"

        Response.AppendHeader("Content-Disposition", "attachment; filename=vCalendar.ics")

        Response.AppendHeader("Content-Length", arrBytData.Length.ToString())

        Response.ContentType = "application/octet-stream"

        Response.BinaryWrite(arrBytData)

        Response.Flush()

        Response.End()

    End Sub

End Class

 
thanks
Jag
June 02

Free Book: .NET Developer's guide to Windows Security

In depth guide to programming Windows Security using .NET is covered in ".NET Developer's guide to Windows Security".  Best of all, it is available FREE to read it on-line. 
 
 
Thanks Keith, for helping .NET developer communities with such a good resource.
Jag
May 21

Learning "LINQ to SQL" queries from SELECT statement: basics

Hai,
 
My first article on "Querying LINQ to SQL" got published here
 
It covers the following (in both VB.NET and C#):
 
-> fetching rows from a table using LINQ
-> Column aliasing and columns of expressions using LINQ
-> DISTINCT values using LINQ
-> ORDER BY using LINQ
-> Filtering rows
-> dealing with IN, LIKE and IS NULL operators using LINQ
 
More to be published soon....
 
thanks
Jag
April 07

Working with "LINQ to SQL Designer" using Visual Studio 2008

Hello,
 
My new article on "LINQ to SQL Designer" got published here http://www.aspfree.com/c/a/.NET/Introducing-LINQ-to-SQL-Designer-using-Visual-Studio-2008/
 
It is very similar to my previous article except that this one focuses on "LINQ to SQL Designer".
 
thanks
Jag.
March 31

Beginning "LINQ to SQL" using Visual Studio 2008

Hai,
 
 
It covers all the following topics:
 
-> Developing a simple "LINQ to SQL" application without using "LINQ to SQL" designer
-> Retrieve and update information using "LINQ to SQL"
-> using DataContext object in LINQ development.
-> Source Code in both Visual Basic and C#
 
Hope it helps.
 
thanks
Jag
 
 
March 13

TIP: Viewing the generated SQL of LINQ statements

Even though LINQ uses the familar syntax as of SQL, it is not the same SQL generated at run-time.  To view the SQL generated from LINQ, we can use "Log" property of "DataContext" in the following manner:
 
              Dim obj As New SampleDAL.SampleDataContext
        Dim s As New StringWriter
        obj.Log = s
        Me.GridView1.DataSource = From p In obj.emps _
                                  Where p.deptno = 10 _
                                  Select p
        Me.GridView1.DataBind()
        Me.Label1.Text = s.ToString
 
You can also make use of VS integrated debugger as shown here
 
Hope this helps...
 
thanks,
Jag

TIP: Modifying Connection String dynamically for a strongly typed dataset in a different assembly

Imagine, I am working on a Visual Studio 2005/2008 solution with class library project (DAL) and Web Application Project (ASP.NET).  Say, the DAL is being developed using Dataset Designer with different Strongly Typed DataSets/DataTables together with TableAdapters.  Then I would certainly run into a problem.
 
The DAL (by default) maintains its own connection string in application configuration settings (app.config) and the ASP.NET application maintains its own connection string in Web.config file.  Any project, by principle, should not contain connection strings at more than one location.
 
To make DAL pickup Connection String automatically from web.config by itself (without writing any code) during run-time,  simply make sure that the names of connection strings (not the values) are identical in both app.config and web.config.
 
To make DAL pickup Connection String dynamically from web.config during run-time (at least).  It can be easily accomplished by adding the following code to the "MySettings" class in "Setting.Designer.vb" file.
 
Private Sub MySettings_SettingsLoaded(ByVal sender As Object, ByVal e As System.Configuration.SettingsLoadedEventArgs) Handles Me.SettingsLoaded
            Dim s As MySettings = TryCast(sender, MySettings)
            s.Item("SampleConnectionString") = System.Configuration.ConfigurationManager.ConnectionStrings("cnDev").ConnectionString
        End Sub

 
To make the above work, you may also need to refer to "System.Configuration" in your class library project.
 
 
Hope the above solves the problem...
 
thanks
Jag
 
February 26

TIP: Writing a macro in Visual Studio 2005 to attach a process for debugging purposes

For debugging class libraries, web services etc., we may need to attach the debugger to a running ASP.NET process. 

It is better to write a macro to accomplish the above and use it for any number of times using a simple Key press (with your own key combination).  Following are the steps to achieve the same:

  • Open Visual Studio 2005
  • Press Alt-F8 to bring up Macro Explorer
  • Add a new Module (AttachProcessToWeb) and type in the code as following:
Imports System
Imports EnvDTE
Imports EnvDTE80
Imports System.Diagnostics
Imports EnvDTE90
Imports System.IO
Public Module AttachProcessToWeb

    Public Sub AttachProcess()
        Dim process As EnvDTE.Process
        For Each process In DTE.Debugger.LocalProcesses
            If (Path.GetFileName(process.Name).ToLower() = "aspnet_wp.exe") Then
                process.Attach()
                Exit Sub
            End If
        Next
        MsgBox("No ASP.NET Development Server found")
    End Sub

End Module
  • Configure Keyboard shortcut using Tools || Options as following:

image

January 29

TIP: Copying DLLs automatically on every successful solution build

Hi,

During a multi project/solution development, we would always copy DLLs or other executables from source folder to destination folder on every successful build.  We can configure our Visual Studio Project in such a way that it copies DLLs (or executables or even other files from any folder) to the destination folders automatically for every successful build.

Here is how it can be accomplished (using Project Properties).

Visual Studio Project Settings for Copying DLLs automatically

Any DOS command, Executable tools or even Batch files (.bat) are accepted as part of command line.

Hope it helps...

thanks

Jag

January 02

Opening a Popup and refreshing parent (when closed) using ASP.NET

The following is the source code which demonstrates the opening of a popup (from gridview), adding/editing a record in popup and finally refresh the parent window upon closing the popup using ASP.NET:
 
 
 
thanks
Jag
December 18

Microsoft Architecture and related Reference Posters

.NET Framework 3.5 Common Namespaces and Types

http://download.microsoft.com/download/4/a/3/4a3c7c55-84ab-4588-84a4-f96424a7d82d/NET35_Namespaces_Poster_LORES.pdf

 

Microsoft® Silverlight™ 1.1 Alpha Developer Reference

http://www.microsoft.com/downloads/details.aspx?FamilyID=811D8AD6-8D48-4684-B08C-686462D58A56&displaylang=en

 

Visual C# 2008 Keybinding Reference

http://www.microsoft.com/downloads/details.aspx?familyid=e5f902a8-5bb5-4cc6-907e-472809749973&displaylang=en

 

Visual Basic 2008 Keybinding Reference

http://www.microsoft.com/downloads/details.aspx?familyid=255b8cf1-f6bd-4b55-bb42-dd1a69315833&displaylang=en

 

Visual C++ 2008 Keybinding Reference

http://www.microsoft.com/downloads/details.aspx?FamilyID=4411BBFC-0E3C-42B3-BD05-AF1D292C986F&displaylang=en

 

Visual C++ 2005 Keyboard Shortcut Reference

http://www.microsoft.com/downloads/details.aspx?FamilyID=bccf84f4-4136-48b2-b4ec-83eaa484da20&DisplayLang=en

 

Visual Basic 2005 Keyboard Shortcut Reference

http://www.microsoft.com/downloads/details.aspx?familyid=6bb41456-9378-4746-b502-b4c5f7182203&displaylang=en&tm

 

All Visual Studio 2003 posters

http://msdn2.microsoft.com/en-us/vstudio/aa700892.aspx

 

2007 Office System Document: Developer

http://download.microsoft.com/download/0/9/c/09cda3f2-6d3d-4082-aec5-9a62b7679ecf/2007OfficeDeveloperMap.pdf

http://download.microsoft.com/download/0/9/c/09cda3f2-6d3d-4082-aec5-9a62b7679ecf/InfoPathObjectModelMap.pdf

 

PnP Overview

http://www.microsoft.com/downloads/details.aspx?FamilyID=d99fb3dd-e753-4500-bdad-e59ac0cea903&DisplayLang=en

 

Smart Client

http://www.microsoft.com/downloads/details.aspx?FamilyID=523bf8a4-2b48-459b-9a2a-19cfabad08dc&DisplayLang=en

 

Exchange

http://www.microsoft.com/downloads/details.aspx?FamilyId=FDCDF6E5-DE47-4B58-8086-282101BCDDE9&displaylang=en

 

Active Directory

http://www.microsoft.com/downloads/details.aspx?familyid=c236336d-ab43-44b1-ad6f-a2f668fb8c02&displaylang=en

 

Windows Server 2008 (Active Directory & Feature Components)

http://www.microsoft.com/downloads/details.aspx?FamilyID=c2b9e44e-0bbd-47cb-bc09-b3d48be7f867&DisplayLang=en

 

BizTalk Server 2006 Capabilities

http://www.microsoft.com/downloads/details.aspx?FamilyID=00a6472c-14df-4da8-8d77-6aa2315b5862&displaylang=en

 

BizTalk Server 2006 R2 Capabilities

http://www.microsoft.com/downloads/details.aspx?familyid=34F41573-C552-466F-B531-32CB09A57CDD&displaylang=en

 

BizTalk Server 2006 R2 Runtime Architecture

http://www.microsoft.com/downloads/details.aspx?familyid=8790E652-1DA5-4E80-88FE-B87606233DB4&displaylang=en

 

Hope you find those posters quite useful...
 
thanks
Jag

Working efficiently with multiple T-SQL stored procedure parameter values

Sending multiple values in the form of array to a SQL Server stored procedure is very common among database developers.  We can send the values in either of the two methods as following:

 

·          Comma separated values (in a single string)

·          XML document (in a single string)

 

This post focuses on comma separated values.

 

The following converts a parameter containing a string (array) of values (separated by commas) to a table:

 

CREATE FUNCTION dbo.ParmsToList (@Parameters varchar(500))

returns @result TABLE (Value varchar(30))

AS  

begin

     DECLARE @TempList table

          (

          Value varchar(30)

          )

 

     DECLARE @Value varchar(30), @Pos int

 

     SET @Parameters = LTRIM(RTRIM(@Parameters))+ ','

     SET @Pos = CHARINDEX(',', @Parameters, 1)

 

     IF REPLACE(@Parameters, ',', '') <> ''

     BEGIN

          WHILE @Pos > 0

          BEGIN

               SET @Value = LTRIM(RTRIM(LEFT(@Parameters, @Pos - 1)))

               IF @Value <> ''

               BEGIN

                    INSERT INTO @TempList (Value) VALUES (@Value)

               END

               SET @Parameters = RIGHT(@Parameters, LEN(@Parameters) - @Pos)

               SET @Pos = CHARINDEX(',', @Parameters, 1)

 

          END

     END    

     INSERT @result

     SELECT value

        FROM @TempList

     RETURN

END   

The above function can be tested with the following statement:

 

select * from dbo.ParmsToList ('1001,2323,jagadish,pulakhandam,3232')

 

We can utilize the above function and scale out to more functions according to our requirements.  For example, I would like to have an “IN” parameter list to be returned for a given string of comma separated values.  I can implement a new function (which in-turn invokes the above function) as following:

 

create function dbo.ParmsToINValues (@Parameters varchar(500))

      returns varchar(1000)

AS  

begin

      DECLARE @item_table TABLE (primary_key INT IDENTITY(1,1) NOT NULL, --THE IDENTITY STATEMENT IS IMPORTANT!

                               item varchar(200)

                              )

 

      insert into @item_table select * from dbo.ParmsToList (@Parameters)

 

      DECLARE @item varchar(200)   

      DECLARE @item_counter INT

    DECLARE @loop_counter INT

      DECLARE @result varchar(1000)

    SELECT @loop_counter = COUNT(*) FROM @item_table

    SET @item_counter = 1

      SET @result = ''

 

            WHILE @loop_counter > 0 AND @item_counter <= @loop_counter

    BEGIN

            SELECT @item = item

        FROM @item_table

        WHERE primary_key = @item_counter

            SET @result = @result + '''' + @item + ''','               

        SET @item_counter = @item_counter + 1

    END

      SET @result = LEFT(@result,LEN(@result)-1) -- trim last comma

      return @result

END

 

To test the above function, we can use the following script:

 

declare @result varchar(1000)

set @result = dbo.ParmsToINValues('1001,2323,jag,chat,3232')

print 'select * from emp where empid in (' + @result + ')'

 

The resulting output would be as follows:

 

select * from emp where empid in ('1001','2323','jag','chat','3232')

 

Hope the post is useful….

 

Thanks

Jag

 
List of my published articles
Free Visual Studio 2005/2008 add-ins/plug-ins which boost your productivity