DataSetHelper.SelectDistinct method for multiple columns

UPDATE: In .Net 2.0 there is DataView.ToTable Method (String, Boolean, String[]) that does, what my function (and MS KB  article 326176) was created to address. The article is now obsolete.

UPDATE: there is also optimized for performance class in CodeProject DataTable with SelectDistinct in VB .

I was using a DataSetHelper class based on MS kb article 326176 HOW TO: Implement a DataSet SELECT DISTINCT Helper Class.

However SelectDistinct  function from the article works only if you select distinct on single field.
To support multiple fields I created a function, based on Nageswara Reddy's post .

            public static DataTable SelectDistinct( DataTable SourceTable, string[] FieldNames)

            {// select distinct on multiple fields.

//From: Nageswara Reddy

            FieldNames = StringHelper.ToLower(FieldNames);

            DataTable DistinctTable = SourceTable.Clone();

                  DataColumn [] constraintColumns = new DataColumn[FieldNames.Length];

            int nFound=0;

                  for (int i =0 ; i< DistinctTable.Columns.Count ; i++)


                if (Array.IndexOf(FieldNames, DistinctTable.Columns[i].ColumnName.ToLower()) >= 0)


                    if (nFound >= FieldNames.Length)


                        throw new ApplicationException("Too many fields are similar to passed FieldNames " + FieldNames.ToString());


                    constraintColumns[nFound++] = DistinctTable.Columns[i];



            //Report if passed field names are not found in the table

            if (nFound < FieldNames.Length)


                throw new ApplicationException("Some of fields " + FieldNames.ToString() + " not found in the database");


                  UniqueConstraint _UniqueConstraint = new UniqueConstraint(constraintColumns);



                  for (int i =0 ; i< SourceTable.Rows.Count ; i++)






                        catch(Exception ex)

                        { // Keep quite




                  return DistinctTable;



See also my previous post: “Handling missing source columns in DataSetHelper.InsertInto method”

Batch to Logging Worker Process Recycling Events in IIS 6.

I want to log Worker Process Recycling Events in IIS 6.0 (IIS 6.0) , but ther is no UI for this.
I've created batch file and decided to post it here, because current instructions have a few typos.
You should modify value of AppPoolName as appropriate.

:rem IISLoggingWorkerProcessRecycling.bat
:rem from
set EnableEvent=true
set AppPoolName=ASP.NET v2.0
cd %systemDRIVE%\inetpub\adminscripts
cscript adsutil.vbs set "w3svc/AppPools/%AppPoolName%/AppPoolRecycleTime" %EnableEvent%
cscript adsutil.vbs set "w3svc/AppPools/%AppPoolName%/AppPoolRecycleRequests" %EnableEvent%
cscript adsutil.vbs set "w3svc/AppPools/%AppPoolName%/AppPoolRecycleSchedule" %EnableEvent%
cscript adsutil.vbs set "w3svc/AppPools/%AppPoolName%/AppPoolRecycleMemory" %EnableEvent%
cscript adsutil.vbs set "w3svc/AppPools/%AppPoolName%/AppPoolRecycleIsapiUnhealthy" %EnableEvent%
cscript adsutil.vbs set "w3svc/AppPools/%AppPoolName%/AppPoolRecycleOnDemand" %EnableEvent%
cscript adsutil.vbs set "w3svc/AppPools/%AppPoolName%/AppPoolRecycleConfigChange" %EnableEvent%
cscript adsutil.vbs set "w3svc/AppPools/%AppPoolName%/AppPoolRecyclePrivateMemory" %EnableEvent%