C
C
Coops2018-02-20 00:13:03
C++ / C#
Coops, 2018-02-20 00:13:03

How to build a C# program from a database?

Hello!
There is a C# program with a database (MS SQL), I use Visual Studio 2015.
The database itself is in My Documents, it is not copied when the program is assembled, and the paths to the database in the program do not change.
It turns out that the program works on my computer, since I have a database and the path to it cannot be changed.
I know that you can somehow do it so that when you build the program, the database is copied to the destination folder and the paths change.
Tell me how to do it? Tried in different ways, but nothing comes out.
5a8b3d4aa1644317712353.png

Answer the question

In order to leave comments, you need to log in

3 answer(s)
#
#, 2018-02-20
@mindtester

in general, that is, the concept of connection string is a connection string , it is either in some program configs or in the program text. it depends on the driver used (ADO, DAO, ODBC... maybe even Entity Framework or Linq to SQL)
and so this line is guaranteed to contain an absolute or relative (for example, relative to the user profile) path to the database file
if you have the sources project (and even if not) - from the program/project folder, search for files by *.* mask containing a substring with the name of the database, in explorer, spotlight, total commander ... anyway .. in any file tool that you know how to use . such a file is sure to be found, then it will be much easier to understand how to manage the situation

P
Ptolemy_master, 2018-02-20
@Ptolemy_master

In the studio, select the file, then in the properties find "Build Action", specify "Content" and "Copy to output directory" specify "Copy Always" or "Copy if Newer" (if it changes, it will be copied only if it changes).

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question