windows 8.1 apps are not downloading


Hi There

if you are struck with the weird problem, that windows is unable to download your app, even though you asked it to…

and the app simply sits in the pending status, it might be because of your connection settings…

Yes, the internet connection settings, called metered connections.

Windows 8 / 8.1 have put in a good stuff to stop the download on metered connections, if the internet is chargeable, in order reduce the cost,

Coming to solution of how to get rid of the metered connection use the below

  1. Swipe in from the right edge of the screen, tap Settings, and then tap Change PC settings.
    (If you’re using a mouse, point to the upper-right corner of the screen, move the mouse pointer down, click Settings, and then click Change PC settings.)
  2. Tap or click Network, and then tap or click Connections.
  3. Tap or click the connection you want to change, and then, under Data usage, turn Set as a metered connection on or off.

if this have solved your problem please do let me know through the comments.

 

Advertisements

Audit the data changes using triggers


Hi Every one

Although SQL Server have introduced the functionality of audit on data itself, it is not available in all the versions except for the enterprise endition. As a alternative we can keep a trigger on each table for writing the before and after data. The below code consists of a table audit_change_log which will hold the data and the SP uspAudit will create the triggers on the tables.

if exists ( select 1 from sys.tables where name = 'Audit_Change_log')
    drop table Audit_Change_log
GO

create table Audit_Change_log
(
     ID             BIGINT          IDENTITY(1,1)
    ,tableName      Varchar(100)    NOT NULL
    ,previousData   VARCHAR(MAX)    NULL
    ,CurrentData    VARCHAR(MAX)    NULL
    ,UpdtTime       DATETIME        DEFAULT GETDATE()
    ,operation      VARCHAR(20)     NULL
)

GO

IF EXISTS ( SELECT 1 FROM sys.procedures where name = 'uspAudit')
    DROP procedure uspAudit
GO

CREATE procedure uspAudit
(
     @action         CHAR(1) = 'C'
)
AS
BEGIN
    DECLARE @SQL        NVARCHAR(4000)
    DECLARE @SQ         NVARCHAR(4)
    DECLARE @tblName    NVARCHAR(500)
    BEGIN TRY
        SET @SQ = ''''
        DECLARE abcd CURSOR
        FOR SELECT name FROM sys.tables where name <> 'Audit_Change_log'
        OPEN abcd
        FETCH abcd into @tblName
        WHILE @@FETCH_STATUS = 0
        BEGIN
            IF NOT EXISTS ( SELECT 1 FROM information_schema.columns where table_name = @tblName AND Data_type in ('text','ntext','image'))
            BEGIN
                SELECT @SQL = 'IF OBJECT_ID (' + @SQ + 'trg_' + @tblName + @SQ + ',' + @SQ + 'TR' + @SQ +') IS NOT NULL DROP TRIGGER ' + 'trg_'+@tblName + ';'
                --select @SQL
                EXEC(@SQL)
                SELECT @SQL = 'CREATE TRIGGER trg_'+@tblName+' ON ' + @tblName + ' AFTER INSERT, UPDATE, DELETE AS ' +
                                + ' INSERT INTO  Audit_Change_log (tableName,previousData,CurrentData) SELECT ' + @SQ +  @tblName + @SQ + 'AS tableName '
                                +', (select * from deleted for XML AUTO) AS previousData, (select * from inserted for XML AUTO) as CurrentData; '
                                + ' UPDATE  Audit_Change_log SET  operation = CASE  WHEN previousData IS NULL THEN ' + @SQ +  'Insert'  + @SQ
                                + ' WHEN CurrentData IS NULL THEN ' + @SQ + 'Delete' + @SQ
                                + ' ELSE ' + @SQ + 'Update' + @SQ + ' END WHERE ID = @@IDENTITY ;'
                --select @SQL
                EXEC (@SQL)
            END
            ELSE
            BEGIN
                SELECT @SQL = 'IF OBJECT_ID (' + @SQ + 'trg_' + @tblName + @SQ + ',' + @SQ + 'TR' + @SQ +') IS NOT NULL DROP TRIGGER ' + 'trg_'+@tblName + ';'
                EXEC(@SQL)
                SELECT @SQL = 'CREATE TRIGGER trg_'+@tblName+' ON ' + @tblName + ' AFTER INSERT, UPDATE, DELETE AS ' +
                                + ' INSERT INTO  Audit_Change_log (tableName,previousData,CurrentData) SELECT ' + @SQ +  @tblName + @SQ + 'AS tableName '
                                +', (select '  + (select stuff((select ','+column_name from information_schema.columns where data_type not in ('text','ntext','image') and table_name = @tblName for xml path('')  ),1,1,''))
                                + ' from deleted for XML AUTO) AS previousData'
                                + ', (select '+  (select stuff((select ','+column_name from information_schema.columns where data_type not in ('text','ntext','image') and table_name = @tblName for xml path('')  ),1,1,''))
                                + ' from inserted for XML AUTO) as CurrentData;'
                                + ' UPDATE  Audit_Change_log SET  operation = CASE  WHEN previousData IS NULL THEN ' + @SQ +  'Insert'  + @SQ
                                + ' WHEN CurrentData IS NULL THEN ' + @SQ + 'Delete' + @SQ
                                + ' ELSE ' + @SQ + 'Update' + @SQ + ' END WHERE ID = @@IDENTITY ;'
                EXEC (@SQL)

            END
            FETCH abcd into @tblName
        END
        CLOSE abcd
        DEALLOCATE abcd
    END TRY
    BEGIN CATCH
        CLOSE abcd
        DEALLOCATE abcd
        SELECT CAST(ERROR_LINE() AS VARCHAR) +':' +      ERROR_MESSAGE()
    END CATCH
END
GO

EXEC uspAudit