Wednesday 28 January 2015

Run this Query and Feel Difference between @@IDENTITY SCOPE_IDENTITY() and IDENT_CURRENT

---Run this Query in ur Query window of SQL and feel  the difference! ;)

IF object_id('tempdb..#IndexDetails') IS NOT NULL
                                  DROP TABLE #IndexDetails;
                                  CREATE TABLE #IndexDetails (
                                  Id INT IDENTITY(1, 1)
                                  ,IndexID INT DEFAULT(0))
                                 
IF object_id('tempdb..#IndexDetails2') IS NOT NULL
                                  DROP TABLE #IndexDetails2;
                                  CREATE TABLE #IndexDetails2 (
                                  Id INT IDENTITY(1000, 1)
                                  ,IndexID INT DEFAULT(0))
                                               
INSERT INTO #IndexDetails (IndexID)
VALUES(1001)

INSERT INTO #IndexDetails2 (IndexID)
VALUES(1001)

SELECT @@IDENTITY
SELECT SCOPE_IDENTITY()
SELECT IDENT_CURRENT ('#IndexDetails') AS Current_Identity;


Thursday 22 January 2015

How to unlock Wallpaper in Windows 7 locked down by domain group policy?



HKCU\Software\Microsoft\Windows\CurrentVersion\Policies\System


there's a key called Wallpaper.  delete it and re-set the desktop background.

It works ;)

Click once rmove from XP / Windows 7

If the OS is Windows 7, the folder should be users\[username]\appdata\local\apps\2.0
If the OS is Windows xp, the folder should be Documents and Settings\[username]\Local Settings\apps\2.0
If it doesn't work, you try to remove the clickonce application manually.
First, clean the ClickOnce cache folder again.
Second, open registry editor, find and delete the associated key under HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Uninstall\
Third, delete the shortcuts of the clickonce application.
After manually remove the clickonce application, try install it again.


Acrobat Help / Display PDF in browser | Acrobat, Reader XI

If you are using adobe reader for your web application. Please make sure that it is Enabled in the IE.


1.Open Internet Explorer, and choose Tools > Manage Add-ons.

2.Under Add-on Types, select Toolbars And Extensions.

3.In the Show menu, select All Add-ons.

4.In the list of add-ons, select Adobe PDF Reader.

Note:If you do not see the Adobe PDF Reader add-on, try the other options on the menu. For example, on some systems, the add-on appears when you select Run Without Permission.

5.Click the Enable or Disable button (it toggles depending on the status of the selected add-on):

Enable sets the Adobe PDF Reader add-on to open PDFs in the browser.


Disable turns off the add-on so it does not open PDFs in the browser.

install .net 4.0 in IIS

cd %windir%\Microsoft.NET\Framework\v4.0.30319

aspnet_regiis.exe -i

How to make IIS7 play nice with Office Interop

STEP 1 :
I’ve just started working on a new project for which we had to dig out one of our older libraries. We wrote it to retrieve data from MS Excel workbooks using the Office interop assemblies, and thus far it has never given us issues. A slight change this time round was that we were using our library in an ASP.NET site rather than a desktop application. As a result I was faced with two errors that we’d never seen before.
Error Message:
Retrieving the COM class factory for component with CLSID {00024500-0000-0000-C000-000000000046} failed due to the following error: 80070005 Access is denied. (Exception from HRESULT: 0×80070005 (E_ACCESSDENIED)).
Solution:
This is a COM permissions problem.
1.       Start > Run > dcomcnfg (or “mmc -32″ and then add the Component Services snap-in manually if you can’t find the app under step 3)
2.      Navigate to Component Services > Computers > My Computer > DCOM Config
3.      Locate the MS application giving you trouble (eg: “Microsoft Excel Application” for Excel or “Microsoft Word 97 – 2003 Document” for Word)
4.      Right click > Properties
5.      On the security tab: Select Customize under Launch and Activation Permissions and click Edit…
6.      Add the account under which the site is running (eg: Network Service) and assign Local Launch & Local Activation permissions
7.      Voila!
Error Message:
[COMException (0x800a03ec): Microsoft Excel cannot access the file '<filename>'. There are several possible reasons:
• The file name or path does not exist.
• The file is being used by another program.
• The workbook you are trying to save has the same name as a currently open workbook.
Solution:
This seems to be an issue with Excel/Word/etc not having access to a profile when being started via the interop route.
1.       Open Windows Explorer
2.      Depending on whether you installed a 32bit or 64bit version of office you will need to do one  (or both) of the following:
A.     32bit Office installation: Navigate to C:\Windows\System32\config\systemprofile
B.     64bit Office installation: Navigate to C:\Windows\SysWOW64\config\systemprofile
3.      Verify the folder “Desktop” exists (create it if it’s not there)
4.      Right click > Properties
5.      On the security tab: Add the account under which the site is running (eg: Network Service) with default permissions (Read & execute; List folder contents; Read)
6.      Voila!

To reinstall .Net Version on server (Not needed on most cases)
C:\Windows\Microsoft.NET\Framework\v4.0.30319\aspnet_regiis.exe -i

 Cannot find Microsoft Word Application in DCOM


On 64 bit system with 32 bit Office try this:
1.       Start
2.       Run
3.       mmc -32
4.       File
5.       Add Remove Snap-in
6.       Component Services
7.       Add
8.       OK
9.       Console Root
10.    Component Services
11.    Computers
12.    My Computer
13.    DCOM Config

14.    Microsoft Excel Application


if error System.Runtime.InteropServices.COMException (0x800706BE): The remote procedure call failed. (Exception from HRESULT: 0x800706BE)
then check.


http://support.microsoft.com/kb/2461206


Other Solutions
1: you must change the identity of word component in windows\System32\comexp.msc to be interactive user instead of launching user.
2:
0. Set the DCOM Config Setting for "Microsoft Office Word 97 - 2003 Document"
(Open the properties > Identity Tab > Select "The interative User" Secutiry Tab > Lanuch and Acctivation Permissions > Add Network Serivce
  1. Save the settings
  2. Open your Virtual directory in IIS
  3. Select the Virtual directory
  4. Select "Authentication".
  5. Edit anonymous authentication
  6. Dialog box will get opened > click on set > admin user (any admin user is good)

Enable logging using diagnostics for Web application

<configuration>
<system.diagnostics>
    <sources>
      <source name="System.ServiceModel"
              switchValue="Error">
        <listeners>
          <add name="traceListener"
              type="System.Diagnostics.XmlWriterTraceListener"
              initializeData= "Traces.svclog" />
        </listeners>
      </source>
    </sources>
  </system.diagnostics>
   
</configuration>