24 September 2015

Run Windows 10 Applications as Administrator by Default

Impostare il file "subst.exe" (o anche solo "subst") nel registry! Così, senza percorso.



The workaround to solve the problem cause by another respectfulness from Microsoft towards its customers, is a small registry hack. All you need to do, is to add your application's full path to the following path in Registry under Current User key:

HKCU\Software\Microsoft\Windows NT\CurrentVersion\AppCompatFlags\Layers


Trovato qui.

16 September 2015

CreateUserWizard localization

Seems like ASP.NET at some point overrides CreateUserButtonText value.

To get around it, just override it again:
protected void Page_PreRender(object sender, EventArgs e)
{
    CreateUserWizard1.CreateUserButtonText = "Crea utente";
}

Via.

08 September 2015

DELETE, TRUNCATE and RESEED Identity

We'll see how the identity column behaves when there is DELETE, TRUNCATE or RESEED Identity is used.

Create a temp table with Identity column beginning with value 11. The seed value is 11.
USE [TempDB]
GO
-- Create Table
CREATE TABLE [dbo].[TestTable](
[ID] [int] IDENTITY(11,1) NOT NULL,
[var] [nchar](10) NULL
) ON [PRIMARY]
GO
-- Build sample data
INSERT INTO [TestTable]
VALUES ('val')
GO

When seed value is 11 the next value which is inserted has the identity column value as 11.
ELECT *
FROM [TestTable]
GO


Effect of DELETE statement
-- Delete Data
DELETE FROM [TestTable]
GO

When the DELETE statement is executed without WHERE clause it will delete all the rows. However, when a new record is inserted the identity value is increased from 11 to 12. It does not reset but keep on increasing.
-- Build sample data
INSERT INTO [TestTable]
VALUES ('val')
GO
-- Select Data
SELECT *
FROM [TestTable]



Effect of TRUNCATE statement
-- Truncate table
TRUNCATE TABLE [TestTable]
GO


When the TRUNCATE statement is executed it will remove all the rows. However, when a new record is inserted the identity value is increased from 11 (which is original value). TRUNCATE resets the identity value to the original seed value of the table.

-- Build sample data
INSERT INTO [TestTable]
VALUES ('val')
GO
-- Select Data
SELECT *
FROM [TestTable]
GO


Effect of RESEED statement

If you notice I am using the reseed value as 1. The original seed value when I created table is 11. However, I am reseeding it with value 1.
-- Reseed
DBCC CHECKIDENT ('TestTable', RESEED, 1)
GO


When we insert the one more value and check the value it will generate the new value as 2. This new value logic is Reseed Value + Interval Value – in this case it will be 1+1 = 2.

-- Build sample data
INSERT INTO [TestTable]
VALUES ('val')
GO
-- Select Data
SELECT *
FROM [TestTable]
GO


Here is the clean up act.
-- Clean up
DROP TABLE [TestTable]
GO


Testato su SQL 2008 R2.
Trovato qui.