Visual Studio 2016.
I still know how to work with a database only this way: I create a database in (localDb) \ Projects, generate a table from a file with a sql script, then pull out or write data using SqlCommand.
Is it included in the project so that the program runs on another computer? I have some doubts.
Browsing SQL Server objects from my database

If it doesn’t turn on, please explain on fingers for such a club like me - is it possible to create a local database inside the project so that it can also work with queries in the same way?

If you click "Create item", there are three options, "Database, based on services", "Local Database", "Data Set". Each of the options involves a bunch of different settings that I think nafig did not give up. I thought, since I need a local database, then the Local Database option is the most logical one. But everything is not so simple.
I looked at the "Data Set" - I immediately saw that there were no requests, and closed it. If you choose local, then there are 2 more options - "Data Set", "EDM Data Model". The fact that there is again a set of data confuses me. The data model was created for a long time, but I need to actually draw a model there, which I do not need.
In short, I didn’t understand something, please help the fool.

"PCM on the project-> Add -> Create item ..." Dialog box after selecting the option "Local DB"

  • one
    I think it is worthwhile to google codefirst ( for example ) or here it can help - Batanichek
  • Thanks for the links, just not a hint of working with queries neither there nor there: / - Max
  • 2
    If you use MS SQL LocalDB, then on a clean computer you will need to install: SQL Server Express LocalDB, .NET Framewokr, your program. If you don’t want to install anything other than the program, I think you can look in the direction of SQLite - MaximK

1 answer 1

  1. Create a project;
  2. Data Sources - Add a new data source ;
  3. Database - Data Set - Create Connection , enter the name of the database file. ( Use Windows Authentication ). Check Yes, save connection as - Done ;

Here you have an empty local database connected to your application. When compiling, your DB file will be copied to the folder with your program.

Your database appears in Database Explorer . Select it, click the right mouse button in the menu, select New request . There you execute your sql script to create the base structure. Either by handles, open the subfolder Tables , Stored procedures , Views , etc. and there you create everything you need.

After that, in the Data Source, select: Configure the data source using the wizard , your database will be shown there. Tick ​​the necessary tables that you need in the program. After they appear as a tree in the data source. You can take any table or its separate column and drag it onto the form. In this case, the automatic creation of the necessary components to display the data.