-1

I use LocalDB (.MDF) for, VS 2022 community on PC1. I connected C# WinForms App to localdb .MDF file with OpenFileDialog and everything works on PC1, but I would like to run that WinForms App with same MDF file on PC2 without VS 2022. I transfered bin\Debug Folder to PC2.

PC2 error message:
Error Message Here is DB Connection Link (textBox1.Text is MDF file path): conn.ConnectionString = @"Data Source=(localdb)\MSSQLLocalDB; AttachDbFilename="+ textBox1.Text +"; Integrated Security=True;";

  • 1
    *"I have installed MS SQL, VS 2022 and SQL EXPRESS on PC1"* As MS SQL is SQL Server and SQL Express is an edition of SQL Server, are you saying you've installed SQL Server twice..? A licenced edition (standard?) and an express edition? – Thom A Sep 27 '22 at 10:41
  • [Please do not upload images of code/data/errors when asking a question.](//meta.stackoverflow.com/q/285551) – Thom A Sep 27 '22 at 10:42
  • 1
    You're connection string also uses localdb. That isn't Express or an installed version of SQL Server. – Thom A Sep 27 '22 at 10:42
  • I use VS 2022 Community. I mean SSMS as SQL Server and SQL EXPRESS as DB Engine – Benjamin Saralidze Sep 27 '22 at 11:41
  • SSMS <> SQL Server, SSMS (SQL Server Management Studio) is an IDE-like application for SQL Server; please don't use them interchangeably as they are not the same thing at all. Please [edit] your question to correct these errors. As for the latter statement, if you are using SQL Server Express, why is your connection string trying to connect to a localdb? – Thom A Sep 27 '22 at 11:44
  • Thank you. I would like to use only MDF file to process data in WinForms. – Benjamin Saralidze Sep 27 '22 at 11:46
  • Then you aren't using Express, you are using localdb... – Thom A Sep 27 '22 at 11:47
  • Yes but on PC2 won't working and also won's working on another pc without SSMS, Visual Studio AND SQL EXPRESS – Benjamin Saralidze Sep 27 '22 at 11:50
  • You don't need Express, nor Visual Studio or SSMS, installed to use Local DB from an application... Again, SQl Server Express <> Local DB. – Thom A Sep 27 '22 at 11:51
  • 2
    Honestly, I think the real problem here is you don't know what technology you are using, and therefore guessing, what connection strings, settings and installations you should be using, and then wondering why it isn't working. First find out what you actually want/need to be using, and then you can start researching the problem. – Thom A Sep 27 '22 at 11:55
  • I have edited my question but i think you are not focusing for help and real problem. I would like to start App with same MDf on PC2. – Benjamin Saralidze Sep 27 '22 at 12:07
  • Then you *don't* want locals. As it's name suggests, the file is **local**. If you want the same database on 2 (or more) PCs have both connect to a SQL Server instance. – Thom A Sep 27 '22 at 12:20
  • Larnu maybe i asked unclear question. thank you for joining discussion. I use locadb mdf file and it works on PC1. I think as use localdb it must be work on PC 2 but it won't work. – Benjamin Saralidze Sep 27 '22 at 12:27
  • How can i use same mdf file on PC2 without using SQL server? – Benjamin Saralidze Sep 27 '22 at 12:44
  • *"How can i use same mdf file on PC2 without using SQL server?"* you don't. You could *copy* the file, but it wouldn't be the *same* file anymore; it would be a copy of it. – Thom A Sep 27 '22 at 13:04
  • That db.mdf file is from Server where it is running now in SQL Server for Biostar. I don't want to work on the server, therefore I stopped Biostar Service and copy db.mdf file to PC1 where i create Winform App and it works. I only use OpenFileDialog for choose db.mdf file. Now i want use that WinForms App on another pc. I want copy db.mdf file from server to another pc every month and use it for Winform App. – Benjamin Saralidze Sep 27 '22 at 13:22
  • Yes, you can do that. just remember that those are all ***separate*** database files, so no one will see any one else's changes. – Thom A Sep 27 '22 at 13:34
  • That is my problem. I think you understand me. Db.mdf only works on PC1 where i created WinForms App. And also not working on the server as i mentioned. – Benjamin Saralidze Sep 27 '22 at 13:58
  • And, again, if you want people to use the *same* database you need a SQL Server instance... – Thom A Sep 27 '22 at 13:59

1 Answers1

0

Fixed. LocalDB wasn't installed.