Can't connect to database with current setting

We have been running SambaPOS for a few weeks with no problems. Yesterday, the night shift closed with no issues, however, when the morning shift came and tried to start the program they got the following message

The connection string is fine (correct). Clicking OK gives a message to restart and then the same message comes back.

Can anybody give any indication of what is causing this problem and how I should go about resolving it?

is the database engine running?

As far as I know, yes.

You should either know or not know. Can you connect to the database using Management Studio? Maybe try your computer name instead of localhost

Problem is, I am currently out of the country so I don’t have the machine in front of me. I had made the post in the hope someone had seen the problem before and could give a guide where to look. I hadn’t expected such a quick response, so I will check the connection and get back to you tomorrow when I have had a chance to check the machine.

Do you know any reason it would suddenly disconnect from the database when it has been running happily for several weeks? For the same reason I don’t think the problem will be helped by changing from localhost to my computer name

Its not that it lost connection… its that it cant connect to it. So either the database is not running, or something changed.

1 Like

You were right. I asked somebody to check and they have sent back the following

Do you have any ideas what could be causing this?

Not sure what causes this, but I have seen it a few times on my Laptop if it was not shut down properly. It isn’t a SambaPOS issue; rather a Windows issue.

Look in Windows in Control Panel > Administrative Tools > Services. You should see SQL Server in the list and it should be set to Start Automatically. If not, change it so that it does, and either Start the service manually, or reboot to ensure that it does start.

SQL Server also has 2 Authentication methods:

  • Windows Authentication
  • SQL Server Authentication

Both can be supported simultaneously, but if that is not how it was installed, you may need to switch to using one or the other. When you specify the ID and password in the SambaPOS connection string, you are effectively using SQL Authentication. In Management Studio, try both methods to see which works… as I say, both may work, but it must have been set up that way to begin with.

i have this issue quite a lot on my PC, i have to go into task mamager -> services tab -> then click services again and manually start SQL server and all works fine. Ive never found out why its not automatically starting as that is how it set up

Hi all. Thanks for the suggestions. I have now had a look at the system and the database is not running, however when I try to restart it I get the following

In addition, there are various entries in the event log that suggest a rebuild is necessary. The problem now is I cannot see how I can rebuild the database if I can’t connect to it.

If I look at the database using Server Configuration Tools I find that it is trying to log on as a NT AUTHORITY\LocalService as follows

However, if I look at a working connection on my laptop I see the login is NT Sevice\MSSQL$SAMBAPOS4

The original error shows as error number 10054 which it seems can have a number of causes one of which could be the above. I am reluctant to rebuild the database if that is not the real problem. (I haven’t tried a different login as the password I need is in a different location which is a 2 hour trip).

Unfortunately, I do not know sufficient about the workings of SQL server to be sure of how to proceed. So I am in need of some assistance please!

[UPDATE] I have tried logging in as NT Service\MSSQL$SAMBAPOS4 but still can’t start the service. This brings me back to the question of how can I rebuild the database if I can’t connect to it?

typically this error is not really in relation to the login as its more than likely the fact that it does not have permission to the files so it will not start. Did you change any security settings or network settings? Also check if you have compression turned on for the files location. If so turn it off.

This could also mean your .mdf file is corrupted and only way to fix it is to rebuild it.

As you have probably figured out by now there is no way for us to know for sure what is wrong with your system with the information you have provided. It could be a number of issues. Try some of the things I mentioned though.

Also be sure your logged in to windows as an administrator.

I am told, nothing was changed, night shift switched off the machine and it was all working then morning shift switched it back on again and got the error. Compression is not on.

I am unable to connect to the database using the MS SQL Server Management Studio so can you give some indication of how I would go about rebulding the .mdf file

I’ve read running sqldiag.exe may solve that if it is not a file corruption issue.

You can find more info with google about the error and steps to rebuild database.