Temporary table in NAV
I recently found a very interesting blog post about temporary tables by Vjekoslav Babic. It explains really good the different ways a temporary table is handled when used as a parameter . You can basically call a method with a table by value or by reference. When you are using by value the data in the table is copied to a new variable and when you are using by reference you are actual using the same variable as the calling method. This work as expected when not using temporary tables. When it comes to temporary tables you may get an unexpected behavior when using the “by reference”.
Here is an example
The “ByRefereceWrong” will actual delete all records if you are passing a none temporary record to it. A fixed version with verification can be found in “ByRefence” where we use record reference and the ISTEMPORARY method.
Vjekoslav blog post found here does cover some other problem areas as “phantom insert”. I would recommend reading the complete post.
Problem installing demo database
Saurav did get before me in writing this blog post. Have you ever seen below error when installing the demo database.
Could not connect to the SQL database. (-2147467259 master ). This can be caused by insufficient permissions. Indirect permissions through Windows group memberships may not work as expected when User Account Control (UAC) is turned on.
Few resolutions to the problem
1) UAC is turned on.
2) SQL server is not running
3) Your user doesn’t have sufficient privileges on the SQL server.
4) Old database file are left on the system.
Take a look at Saurav’s blog for the solutions. Saurav’s blog post is found here
Every time when adding/deleting a user the NAV service shuts down
Recently I run into a problem where NAV service did shut down every time I did add or delete a user.
The event log explain the problem like bellow. So it obvious that we of some reason can’t connect to the database.
Type: System.Data.SqlClient.SqlException
Class: 14
LineNumber: 1
Number: 916
State: 1
Source: .Net SqlClient Data Provider
ErrorCode: -2146232060
Message: The server principal “XX\YY” is not able to access the database “ZZ” under the current security context.
When looking at the security for database “ZZ” I found the same problem as the event log was pointing at, no trace of user “XX\YY” with gives the NAV service access to the database. It turns out that when adding or deleting a NAV user all user privileges is re-synced, and any user not part of the new list is deleted. And if the NAV service account is not part of the user list, NAV service can’t longer connect to database.
The solution is very simple. You have to make sure that the service account is added as a user in NAV under Tools – Security – Windows Logins. Followed by syncing logins.
Silent or unattended installation on NAV
What is silent or unattended installation
Simply said silent install is installation without any UI. In this case it’s about how to run “setup.exe” in silent mode. It’s recommended that you only run “setup.exe” when you install a new NAV installation, because the installer have been tested by them using this procedure only. So by that said it’s no longer supported to install from the different msi files directly. This is true for all NAV 2009 releases. The major problem you may run into if you are installing directly from the msi files is that you will not get prerequisites (as .Net, Report Viewer and so on) installed and you will also miss out one some pre installs checks (validating that you have everything needed as outlook).
How to-do it?
It’s very simple. “setup.exe” does support some different parameters for this purpose:
/quiet <– will turn of the UI
/log [filename] <– create a log text file in the specified location
/config [filename]<– point to the configuration file to use during the installation
/uninstall <– will simple un install the product
/repair <– repairs a bad installation