Tuesday, December 20, 2011

CRM 2011 - The type initializer for 'Microsoft.Crm.LocatorService' threw an exception.

Typically the following exception :


Exception

An unhandled exception was generated during the execution of the current web request. 
Information regarding the origin and location of the exception can be identified using 
the exception stack trace below.  
The type initializer for 'Microsoft.Crm.LocatorService' threw an exception.


Appear when the iis service is down. In order to solve this problem you have to restart the service and whether an other error occured, as this:


Exception

The IIS Admin Service or the World Wide Web Publishing Service, or a service dep
endent on them failed to start.  The service, or dependent services, may had an
error during its startup or may be disabled.


You must check the related services and the disk space.


Nicola Grillo

Wednesday, November 16, 2011

CRM 2011 - How to find the Guid in CRM Data Base

If you want to find an Guid in the Microsoft Dynamics CRM Database, you should use the following query :



Query

USE <DB_NAME_MSCRM>

Declare @TN as varchar(200), @CN as varchar(200), @myValue varchar(38), @SQL as nvarchar(1000)
, @SN as varchar(200),
Create Table #myTable (Table_Name varchar(200), Column_Name varchar(200), Number_Of_Rows int)

-- Replace @myValue with the value you're searching for in the database
Set @myValue = 'Guidid' 
Declare myCursor Cursor For
Select T.Table_Name, C.Column_Name, T.Table_Schema
From INFORMATION_SCHEMA.TABLES T Inner Join INFORMATION_SCHEMA.COLUMNS C 
On T.Table_Schema = C.Table_Schema And T.Table_Name = C.Table_Name
Where T.Table_Name <> 'dtproperties' And Table_Type = 'Base Table'
And C.Data_Type In ('uniqueidentifier')
-- Replace if you want other type data
--And C.Data_Type In ('text','ntext')
--And C.Data_Type In ('tinyint','int','bigint','numeric','decimal','money','float','smallint','real','smallmoney')
--And C.Data_Type In ('datetime','dmalldatetime')
Open myCursor
Fetch Next From myCursor Into @TN, @CN, @SN
While @@Fetch_Status <> -1
Begin
                EXECUTE ( N'Insert Into #myTable Select ''' + @SN + '.' + @TN + ''', ''' + @CN + ''', Count(*) From [' + @SN + '].[' + @TN + '] Where [' + @CN + '] = CONVERT(uniqueidentifier ,''' + @myValue + ''' )')
                
                Fetch Next From myCursor Into @TN, @CN, @SN
End
Close myCursor
Deallocate myCursor
Select * From #myTable Where Number_Of_Rows > 0 Order By Table_Name
Drop Table #myTable



You should use this query in order to find also other data type.

Nicola Grillo

Wednesday, November 9, 2011