Categories
Dynamics NAV Microsoft PowerShell SQL Server

Import-NAVEncryptionKey : Cannot establish a connection to the SQL Server/Database

If you are sure that the values inserted in the parameters are correct but you are receiving the following error message:

Import-NAVEncryptionKey : Cannot establish a connection to the SQL Server/Database.

This could be due to one of the following reasons:
* SQL Server is not started.
* The database does not exist.
* Proper permissions have not been given to the NAV Server Account.
Try again later or contact your system administrator.
At line:1 char:1
+ Import-NAVEncryptionKey
+ ~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (0:Int32) [Import-NAVEncryptionKey], NavCSideException
+ FullyQualifiedErrorId : Microsoft.Dynamics.Nav.Management.Cmdlets.ImportNavEncryptionKey

Cause:
Maybe the user you are using to run the script does not have access to the db, this is a common issue when you use ‘Database Authentication Mode = SQL Server Authentication’. To be safe use the same account you set up in the instance for the ‘Database Credentials’.

Solution:
Run Windows PowerShell ISE as Administrator and run the following script changing placeholders with the angle brackets (<>) with your values

Set-ExecutionPolicy unrestricted -Force
Import-Module 'C:\Program Files\Microsoft Dynamics NAV\<NavVersion>\Service\NavAdminTool.ps1'

$Credential = (New-Object PSCredential -ArgumentList '<LoginName>',(ConvertTo-SecureString -AsPlainText -Force '<Password>'))

Import-NAVEncryptionKey -ApplicationDatabaseCredentials $Credential -ApplicationDatabaseServer <DatabaseServer> -ApplicationDatabaseName <DatabaseName> -KeyPath '<KeyFilePath>' -ServerInstance <InstanceName> -Force

Did my solution solve your problem? Leave a reply.

Categories
Dynamics NAV Microsoft Office

A call to Microsoft.Dynamics.Nav.OpenXml.Spreadsheet.WorkbookWriter.Create failed

I was using the function Export to Excel from the Config. Package Card in Microsoft Dynamics NAV 2017 when I’ve received the following error message:

A call to Microsoft.Dynamics.Nav.OpenXml.Spreadsheet.WorkbookWriter.Create failed with this message:
Could not load file or assembly ‘DocumentFormat.OpenXml, Version=2.5.5631.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35’ or one of its dependencies. The system cannot find the file specified.

A call to Microsoft.Dynamics.Nav.OpenXml.Spreadsheet.WorkbookWriter.Create failed with this message:
Could not load file or assembly 'DocumentFormat.OpenXml, Version=2.5.5631.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified.

Cause:
Probably Open XML SDK 2.5 for Microsoft Office has not been installed on your computer.

Solution:
Close Excel.
Install Open XML SDK 2.5 for Microsoft Office from Microsoft Dynamics NAV DVD, the installation file is under

Prerequisite Components\Open XML SDK 2.5 for Microsoft Office\

Restart NAV Service after the installation.

Did my solution solve your problem? Leave a reply.