Thursday, February 16, 2017

SQL Error: Exclusive access could not be obtained because the database is in use.

When restoring a database, one of the things you need to do is to ensure that you have exclusive access to the database.  If any other active connection is established with database then restore may get failed.

When trying to do a restore, if any other active connection is established with database you will see these types of error messages:

System.Data.SqlClient.SqlError:  Exclusive access could not be obtained because the database is in use. (Microsoft.SqlServer.Smo)

Resolution:

Make the database in single user mode and then do the restore

ALTER DATABASE AdventureWorks SET SINGLE_USER WITH ROLLBACK IMMEDIATE
GO
RESTORE DATABASE AdventureWorks FROM DISK = 'C:\AdventureWorks.BAK' 
GO

Wednesday, February 15, 2017

Progress Bar in CRM Forms

With new Dynamics CRM versions now we have even more opportunities to play with the UI. We have more choice with regards to layout, more choice with regards to user experience, and implicitly more opportunities to make it better for the user.

In this post I’m going to be talking about adding a progress bar to our Case form, to show the loading of the form. It should look something like this:

NOTE: some of the items presented in this post are not officially “supported”.

Now, let’s add the following script to the to the form and call it from OnLoad event of the form:

function showLoading() {
        //use it to change opacity of main content
document.getElementById('tdAreas').parentElement.style.opacity = '0.1';
        //use it to hide main content
//document.getElementById('tdAreas').parentElement.style.display = 'none';
var newdiv = document.createElement('div');
newdiv.setAttribute('id', 'msgDiv');
newdiv.valign = 'middle';
newdiv.align = 'center';
var divInnerHTML = "";
divInnerHTML += "";
divInnerHTML += "";
divInnerHTML += "";
divInnerHTML += "Please wait…";
newdiv.innerHTML = divInnerHTML;
newdiv.style.background = '#FFFFFF';
newdiv.style.fontSize = '15px';
newdiv.style.zIndex = '1010';
newdiv.style.margin = '0 auto';

newdiv.style.width = document.body.clientWidth;
newdiv.style.height = document.body.clientHeight;
newdiv.style.position = 'relative';
document.body.insertBefore(newdiv, document.body.firstChild);
document.getElementById('msgDiv').style.visibility = 'block';
        //use it to define ms for disable loading
//setTimeout(disableLoading, 500); 
}

function disableLoading() {
if (document.readyState === "complete") {
document.getElementById('msgDiv').style.display = 'none';
document.getElementById(‘tdAreas’).parentElement.style.opacity = ”;
//document.getElementById("tdAreas").parentElement.style.display = 'block';
}

}

Play with CRM!! 

Enjoy!

Friday, January 13, 2017

Reporting Server failed to start - The request failed or the service did not respond in a timely fashion.

Modify the registry to increase the default time-out value for the service control manager. To increase this value to 60 seconds, follow these steps:
       1. Click Start, click Run, type regedit,and then click OK.
       2. Locate and then click the following registry subkey:
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control.
       3.  In the right pane, locate the ServicesPipeTimeout entry.
            Note If the ServicesPipeTimeout entry does not exist, you must créate it. To do this, follow these steps:
    1. On the Edit menu, point to New, and then click DWORD Value.
    2. Type ServicesPipeTimeout, and then press ENTER.
    3. Right-click ServicesPipeTimeout, and then click Modify.
    4. Click Decimal, type 60000, and then click OK.
      This value represents the time in milliseconds befor
            Restart the computer for the changes to take effect.
 Check that SSRS and SSIS services can be started now.