0

I'm very very new to SQL Server, and I have written a program in Visual Studio using C# that uses a table from a database that I have created using SQL Server Management Studio. But if I try to run my program on another device, it either asks for a version of SQL Server to be installed or it fails to connect to the server because I used the local option to create the said database and therefore, the other device doesn't have the permission to connect to it.

I have read somewhere that I should use in-memory databases so that other devices can run this program without connecting to me or needing SQL Server to be installed? Can I store the database somewhere in the project and tell my program to seek it and load it?

TLDR; how to use the features of SQL Server like database and tables while offline and without the need to connect to any server or even the need to install SQL Server itself if possible.

And sorry for my bad English!

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
mhs
  • 1
  • 2
  • Does this answer your question? [How to deploy application with sql server database on clients](https://stackoverflow.com/questions/32956142/how-to-deploy-application-with-sql-server-database-on-clients) – SMor Sep 19 '20 at 12:47
  • 1
    A sql database is a mdf file. The mdf file in c# can be access using localDb (attach database) or you can attach the database to a SQL Server and access the file through the Server. The remote machine should not use Attach Database in the connection string since the database is already attached on another machine.Your issue is you need to configure the database so additional users can access the database.Usually I set up a group account on the machine where database is located.The give the database the group account permissions. The setup the group account on both local and remote machines. – jdweng Sep 19 '20 at 12:48
  • 2
    MS SQL is typically used on a server machine. If you need a local database, SQLite may be an option: https://learn.microsoft.com/en-us/dotnet/standard/data/sqlite/?tabs=netcore-cli – Christoph Lütjen Sep 19 '20 at 12:49
  • Your question is very broad and depends on the database engine you select. You mention "a table" (as in a single table) - do you need a database engine at all for this? Much depends on what features you actually need. TLDR - do some research. – SMor Sep 19 '20 at 12:50
  • @SMor it answers half of the question. Thank You! But I want to know if there's a way to actually bake in the databases and/or tables so that the end user can run the program without having to setup or connect to a server. I couldn't find anything similar to my question so I posted it, but if you can redirect me to a guide or another answered question, I would be very happy :D Thank You again! – mhs Sep 19 '20 at 12:58
  • 1
    No. You need the SQL Server engine installed in the machine before it will work. As someone else said, for a small application you could use a serverless file-based database system such as SqLite to get round this requirement – ADyson Sep 19 '20 at 13:20
  • Thanks to everyone who contributed! I've found my answer in using SQLite, but should I keep it open in case someone can answer how to do the same with SQL Server? Or is it just not possible and I should close it? – mhs Sep 19 '20 at 13:30
  • You're right it's not possible. Sql Server is exactly that - a server - and therefore the software which runs the server must be installed in order to gain access to the databases stored on the machine – ADyson Sep 19 '20 at 15:25
  • 1
    You could "bake in" SQL Server Express (including LocalDb) into your application installer rather than have users install it separately. It will be transparent to your end users what DBMS you use. But you don't need to bother if a SQLite embedded database has all the features you need. – Dan Guzman Sep 19 '20 at 18:20

0 Answers0