How to restore a SQL Server database along with a standalone application? I am new to Microsoft SQL Server. I mostly use MySQL and Firebird databases in my projects.

I have a client who needs to restore some software after his computer crashed.  All that is left is a pen drive with the application and database backup.

I have discovered that this application used Microsoft SQL Server 7 and it comes with three files: the executable, an .MDF and a .LDF file.

I installed the trial version of SQL Server 2012 and defined c:\mssql7\data as the database folder in order to match the original files. I also set the user interface to work with Windows accounts, because I do not know if that application programmer changed the database default user and password.

But when I run the application, it displays this message:


  [DBNETLIB][ConnectionOpen (Connect()).]SQL Server do not exist or
  access denied.


What should I do to restore the database and get it to work with the application?  The original developer cannot be located.

Perhaps the login and password I am using does not match the ones in the restored database files?  Perhaps I have a misconfiguration somewhere, for instance maybe I cannot simply copy the files into the data folder?  Perhaps I need to register the database somehow?



Edit 1: The only thing I found by reading the contents of the executable file was:

Provider=SQLOLEDB
Itegrated Security=SSPI
Persiste Security Info=False
User ID=usuario
Initial Catalog=FVBraganca
DataSource=SCFRANGOS




If you guys want to see the original file, you can download it from my website: 

http://alcantara.net.br/MS_SQL_APP_BUGGY.rar
http://alcantara.net.br/MS_SQL_APP_BUGGY.zip
Good deal with getting the connection string out.  Based on that and the error it looks like you'll need to change some things around with your SQL config.

First, SQL 2012 does not support the database compatibility level for SQL Server 7.  You'll need to go back down to at least SQL Server 2005.

Based on that connection string info the app is for a SQL server named SCFRANGOS.  You can try to create a host entry for SCFRANGOS on the machine you're running the app from and give it the IP of your SQL server, or create it in DNS.

The database name you need to use FVBraganca.  Since you have both the mdf (data) and ldf (log) you can try to reattach the database to your SQL Server.

You also need to create a local user on the server and name it usuario.  Then you need to create a Windows login on the SQL server for usario and that login needs to be added to the FVBraganca dabase as a user.

Alternatively, if you're comfortable with editing the binary you could edit your own connection information into the exe.

Steps:


Install SQL Server 2005 or earlier on your server.  You can download SQL Server 2005 Express from here.  Again, SQL 2005 is the newest version you can use that will support the SQL 7 database format.
Make sure the server where SQL Server is installed can be resolved as SCFRANGOS on your network from wherever you are running the application.  You can add a host entry or an alias in DNS.  Or you can add an entry in the hosts file where you will run the application (c:\windows\system32\drives\etc\hosts typically).  When this step is complete you should be able to receive replies when doing a ping SCFRANGOS from the machine where you want to run the application.
Attach the database and name it FVBraganca.  Connect to SQL Server and run this (assuming your mdf and ldf files are in c:\myapp and are called myapp.mdf and myapp_log.ldf):

CREATE DATABASE FVBraganca
ON (FILENAME='c:\myapp\myapp.mdf'),
&nbsp;&nbsp;&nbsp;&nbsp;(FILENAME='c:\myapp\myapp_log.ldf'),
FOR ATTACH;
GO
Create a user called usario on the server where SQL Server is installed.  Instructions are found here.
Create a login in SQL Server for the user created above

CREATE LOGIN [myserver\usario] FROM WINDOWS
GO  
Add the new login as a user of the database.  If the user already exists you'll need to remove it first so you don't have a mismatch of the security identifiers.  The existing user will have the security identifier tied to it from the original SQL Server where the database was last used.

USE FVBraganca
GO
DROP USER usario
GO
CREATE USER usario FOR LOGIN usario
GO  
Since you don't know what the user needs access to yet you might just want to grant it dbo access to the database.  This is typically not a good idea but in this case it'll be easier until you know for sure what objects in the database the application uses.

sp_addrolemember @rolename='db_owner', @membername='usario'  


That should be it.  As long as the database attaches cleanly I think this should get you going.