You may need to recreate views manually

6 minute read time.
Please note that this is not an exhaustive discussion and but simply represents the things that come to my mind when seeing this error.

Why does it appear?

The can be several reasons why this message appears and it usually comes when there has been a change in the configuration of the system. This maybe as a result of an upgrade, or if the SQL password for the "sa" user has been changed, and the same change has not been affected in CRM.

There are some helpful questions to ask when this happens.

Does the error appear for all users?

If the system administrator can logon but another user can not, you will have to turn on the system logs and see what happens. Start looking at the SQL logs and see if the requests are getting to the database. It may give you enough information to sort out the problem.

Is your database running?

UnableToConnectToDB
[DBNETLIB][ConnectionOpen (Connect()).]SQL Server does not exist or access denied
Driver: MSSQL
Server: UKTRAINING
Database: CRM
LoginName: sa You may need to recreate views manually.

This is symptomatic of a database server that is not running. Can you connect using query analyser or other SQL tool?

If the database is already running.. stop and start the database service and retry.

Have you just restored a backedup database?

The error message can appear when you have a mismatch between database and CRM versions. For example you may get the message if you have restored an earlier Sage CRM version database to an install of a later version of Sage CRM.

Is CRM trying to connect to the correct database?

Go to start\run\regedit\HKEY_LOCAL_MACHINE\SOFTWARE\eware\config click on the CRM beneath that and see the right panel see that default databaseserver name is exactly you have, if it is not, then change it manually. You'll need to do an IISRESET before you try and logon again.

Have you changed the database password?

UnableToConnectToDB
Login failed for user 'sa'
Driver: MSSQL
Server: UKTRAINING
Database: CRM
LoginName: sa You may need to recreate views manually.

This can be symptomatic of when the "sa" password was entered correctly but contains a special character, such as $, in the beginning.

Or more alarmingly it can be symptomatic of someone or something (e.g. a Virus, worm etc) changing the password on the database server.

Note:
If you need to change the "sa" password, the correct thing to do is to logon to CRM, change the database password under Administration>System>Database first, then reset the password in MSSQL, and finally reset IIS and logon to CRM again.

But if the database "sa" password has been reset first, then it will not be known to CRM, so you will not be able to connect to the database. Then you'll need to reset the password in MS SQL to the previous password.

But what if you don't know the database "sa" password? You will first need to reset the "sa" password to something you do know. Then you will have to reset the password in the CRM registry. (Backup the registry before doing this!!!).

In the registry browse to HKEY_LOCAL_MACHINE | SOFTWARE | eWare | Config | [CRM], where [CRM] is the name of the CRM instance.

You can set the DatabasePassword to the new database password in plain text. Do an IISRESET, then you should be able to logon to CRM. Once you have logged on to CRM go and reenter the new password and it will be saved back into the registry in encrypted form.

But how do I recreate views manually?

There is a view in the Sage CRM database called "vsentinel". When CRM first starts up (after an IISRESET) and it finds that vsentinel is not present, it will use this as the trigger to force the recreation of the views based on the definitions stored in meta data. Once the other views have been recreated it then creates the trigger view "vsentinel" again.

To force the recreation of the views do this:

1. Do IISRESET from the Run prompt.
2. Go to the SQL Manager. Take a backup of your CRM SQL Database first.
3. Now through SQL Manager itself, select the CRM SQL Database instance. There you will find an option Views which lists all the Views against it.
4. Select the user view "vsentinel". All CRM views are prefixed with 'v'.
5. Press the Delete key from the keyboard and drop the view.
6. After the IISRESET, try to login to CRM and see whether you are able to log in to CRM now or not.
Have you been editing the Themes CSS files in Sage CRM?
This can seem surprising as it has nothing to do with the database and everything to do with a corrupt CSS file being in the Themes folder.
As part of developing a theme a cascading stylesheet will have to be created and edited that contains the style settings for the new look and feel that is being constructed. But there is a section of the stylesheet that has to be preserved. This is clearly marked in the existing stylesheets.
e.g.
C:\Program Files\Sage\CRM\CRM\WWWRoot\Themes\ergonomic.css
/*
CRM GREEN CUSTOM SETTINGS
DO NOT CHANGE FORMAT BETWEEN 'CRM SETTINGS' TAGS
[CRM SETTINGS]
[INITIALIZATION]
//theme file version
VERSION = 1.0
[COLORS DEFINITION]
//wsEmailclient
COLORCAPTIONBLUE=#6795C3
//TSearchEntryGroup.GetEditHtmlFromContent
...
[FONTS]
//WrbTriPage, WsEmailClient
FONTFAMILY=MS P-Mincho
...
[CRM SETTINGS]
*/
The values within this section maybe changed BUT the structure must be preserved. If this section is corrupted or is absent in any css file contained in the Themes folder
C:\Program Files\Sage\CRM\CRM\WWWRoot\Themes\
then it will generate the 'You may need to recreate views manually' message when someone tries to first logon after IIS has been reset. It does not matter is the CSS file is not referenced in translations. All CSS files in the folder are scanned. The origin of the error may be shown in the system log in this case.

So What happens if I still can't log on?

Remember this was not an exhaustive article. Don't panic. Think about what has just changed in the system? Have you applied a new component? Can you restore to the prior state? Have a good look through the forums and knowledge base and then log a case with support. It is almost certain that your problem has been seen before and that support will know what to do.

I hope that this article has helped.

If you have further hints and tips based on your experience then please feel free to post them as comments to this blog article.
  • I would also recommend ensuring the SQL port is not being blocked (even on an existing system where the error suddenly starts to appear).

    You could do this by using Telnet via Command Prompt, to use telnet, follow the steps below:

    1) Make a note of the server name and port of the SQL server.
    2) On the CRM server, select the Windows key and the R key.
    3) In the Run box type CMD.
    4) Select OK.
    5) Type Telnet SERVERNAME PORT - (Replace the SERVERNAME and PORT with the relevant details).

    If you see a blank cursor then the connection is fine. You can close the command prompt window.

    If you receive the message that 'telnet' is not recognized as an internal or external command, operable program, or batch file, you will want to enable Telnet.

    To enable Telnet, follow these steps:

    1) Select Start > Control Panel > then Programs and Features (or Programs)
    2) Select Turn Windows Features on or off
    3) Check the box for both Telnet Client and Telnet Server
    4) Select OK.

    Verify that you can now Telnet the port.

    If you get an error or are unable to telnet to the server please contact your Network Administrator.

  • Greg

    I think that question could be best posted in the forums. But as for the use of alias then Sage CRM is happy for both column and table aliases to be used. Have a look at the Company view vAtRiskCustomers.

  • Jeff,

    I have a question related to views in CRM 7.3. I'm creating a view via the Administration > Customization > Primary Entity Path for reporting/gadget purposes. I noticed by observing some of the native sql scripts in this area of the system that aliases are not used. My issue is that the view was written in SSMS (Sql Server management studio) and is written in such a way that it joins on the company table twice. Additionally, i'm using a Case statement in my Select clause so i need the alias to distinguish it from the other columns in my query. Should I just re-write the view? Is it not possible to insert a view into CRM that cause on the same table twice? Any assistance you can provide would be greatly appreciated.

  • ... Well, you get the gist.

    Looking that UserID up in the UserSettings table showed that UserID=27 had NSet_LoginTo (USet_Key) = "todo" (USet_Value), and was the only one to be like that. Manually changing it to "MyEWare" solved the issue and allowed a successful login. This corresponds with User Preferences / Log In and Session Preferences / Log Me In To Dashboard.