Best way to remove duplicate entries from a data table

DataTable dtIds = GetReservationIds(dtAllReservations);

var duplicates = dtIds.AsEnumerable().GroupBy(r => r[0]).Where(gr => gr.Count() > 1).ToList();

if(duplicates.Any())Console.WriteLine("Duplicate found for Classes: {0}",String.Join(", ", duplicates.Select(dupl => dupl.Key)));
string ceva = String.Join(", ", uniqueIds.AsEnumerable().Select(x => x[0].ToString()));

var UniqueRows = dtIds.AsEnumerable().Distinct(DataRowComparer.Default);
DataTable dt2 = UniqueRows.CopyToDataTable();

How to fix ERR_UNSAFE_PORT error on Chrome when browsing to unsafe ports

Error 312 (net::ERR_UNSAFE_PORT): Unknown error.

Right Click on Chrome shortcut >> Properties >>Then Append --explicitly-allowed-ports=xxx to shortcut target


C:\Documents and Settings\User\Local Settings\Application Data\Google\Chrome\Application\chrome.exe –explicitly-allowed-ports=6666


Not all ports are supported by the web security service. The following is a list of all supported ports:

  • HTTP: 80, 81, 1025-65535
  • HTTPS: 443, 563, 8443
  • FTP: 21



Show database procceses

SELECT @DBName = ‘TransferInventory’
IF EXISTS (SELECT * FROM tempdb..sysobjects WHERE id=OBJECT_ID(‘tempdb..#tmpSpwho2’))
DROP TABLE #tmpSpwho2

CREATE TABLE #tmpSpwho2 (SPID INT, Status VARCHAR(100), Login VARCHAR(100), HostName VARCHAR(100), Blkby VARCHAR(100), DBName VARCHAR(100), Command VARCHAR(50), CPUTime INT,
DiskIO INT, LastBatch VARCHAR(100), ProgramName VARCHAR(100), SPID2 INT, REQUESTID INT)

INSERT INTO #tmpSpwho2 EXEC sp_who2
SELECT ‘kill ‘ + CAST(SPID AS VARCHAR(5)) FROM #tmpSpwho2 WHERE DBName = @DBName

Stocate modificate in utlima vreme

alternativa la view dependencies

select * from sys.objects so JOIN sys.syscomments sc ON WHERE type=’P’ and text like ‘%ReservationCityFees%’

ce stocate au fost modificate in utlimele 7 zile

FROM sys.objects
WHERE type = ‘P’
AND DATEDIFF(D,modify_date, GETDATE()) < 7

‘Operation is not valid due to the current state of the object’ error during postback


System.InvalidOperationException: Operation is not valid due to the current state of the object.

[InvalidOperationException: Operation is not valid due to the current state of the object.]    System.Web.HttpValueCollection.FillFromEncodedBytes(Byte[] bytes, Encoding encoding) +11372207    System.Web.HttpRequest.FillInFormCollection() +329

[HttpException (0x80004005): The URL-encoded form data is not valid.]    System.Web.HttpRequest.FillInFormCollection() +11486290    System.Web.HttpRequest.get_Form() +157    System.Web.HttpRequest.get_HasForm() +11487092    System.Web.UI.Page.GetCollectionBasedOnMethod(Boolean dontReturnNull) +141    System.Web.UI.Page.DeterminePostBackMode() +100    System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)

Uncaught Sys.WebForms.PageRequestManagerServerErrorException: Sys.WebForms.PageRequestManagerServerErrorException: An unknown error occurred while processing the request on the server. The status code returned from the server was: 500


  <add key="aspnet:MaxHttpCollectionKeys" value="1001" />

Microsoft recently (12-29-2011) released an update to address several serious security vulnerabilities in the .NET Framework. One of the fixes introduced by MS11-100 temporarily mitigates a potential DoS attack involving hash table collisions. It appears this fix breaks pages that contain a lot of POST data. In our case, on pages that have very large checkbox lists. Why would this be the case?

Some non-official sources seem to indicate that MS11-100 places a limit of 500 on postback items. I can’t find a Microsoft source that confirms this. I know that View State and other framework features eat up some of this limit.


Alternative reading:

Add Item to Array

There is no Add method for basic arrays.
//Add an item to the end of an existing array
string[] ar1 = new string[] {“I“, “Like“, “To“}

// create a temporary array with an extra slot
// at the end

string[] ar2 = new string[ar1.Length + 1];

// add the contents of the ar1 to ar2 at position 0
ar1.CopyTo(ar2, 0);

// add the desired value
ar2.SetValue(“Code.”, ar1.Length);

// overwrite ar1 with ar2 the contents of ar1 should now be {“I”, “Like”, “To”, “Code.”}
ar1 = ar2;

Array.Resize(ref ar1, ar1.Length + 1);
Array.Copy(new object[] { “Code.” }, 0, ar1, ar1.Length – 1, 1);