0

So I know this should be a simple question you can find everywhere, but I don't know which actions should I take? I have really almost none database work experience.

My situation:

  • I have created a application using c# winforms, there's many forms.
  • I have created a VeiklosDuomenys.mdf with three datatables, they are collected in a dataset VeiklosduomenysDataSet.xsd.
  • Some of the forms connects to the database like this:
cn = new SqlConnection(@"Data Source=(LocalDB)\MSSQLLocalDB;AttachDbFilename=C:\Users\Linas\source\repos\IVS\IVS\VeiklosDuomenys.mdf;Integrated Security=True");

How can I change my database, so it could be more versitile, I want so that when I send debug folder to the another computer, for example in that computer the user just go to register form (inputs data), saves to the local database (there should be no data prior, starts fresh for the user). If there's a need for more information, please tell me, i'll edit by your demands.

EDIT 1:

So I have succesfully with my poor understanding installed the sql server in another computer, now it actually works I can see all the data. When I insert data to the registration form and click register it now says that the .mdf is ReadOnly, so I go to the properties, check all permissions and now I try to run the program again, the result is I get another exception saying "Login Failed for user", now what? Why do I need this, can I just bypass it somehow, this is a school project there's no need for safety. I am using windows authetication and the problem should be that "Integrated security = true" on all my sql connections, if i would set it to false i'll need sql authetication.

I don't even know how to create that user, is it really necessary to use sql authetication? How can I bypass this error the easiest, maybe most dangeruos way?

Tatranskymedved
  • 4,194
  • 3
  • 21
  • 47
Linascts
  • 159
  • 8
  • Do all the applications require the same data set, so you have a centralized DB server? Or are they decentralized, so if you install the application to a new system; the user needs to be setup again? – Stefan Jan 10 '21 at 11:07
  • I don't know if this will answer it, I have 10 forms (4 of them has the connection to VeiklosDuomenys.mdf, the rest don't use any data), they insert or select data from one of the datatables seperatly, I only really used the dataset so I can play with a datagridview, pretty much because to please the syntax, all the datatables are just there, with no relation to each other. – Linascts Jan 10 '21 at 11:13
  • Hi, the actual question is: will you be using the application from multiple computers, and if so: do you want them to see the same data? – Stefan Jan 10 '21 at 11:23
  • The app will just work for the computer it is installed. So there's no need to share data. It's just saving and reading on the computer the database is. It's pretty much like this (the database should work like notepad or somth similar, user register (new data in local database), user logins (read data in local database). – Linascts Jan 10 '21 at 11:26
  • You mdf file is locate in the folder c:\Users\Linas which is your user account. When you install the application in another location you need to put the mdf file is a location that is more accessable than you own user account. – jdweng Jan 10 '21 at 11:33
  • You need to install the files required to handle the mdf file. Even if you use LocalDB See my question here https://stackoverflow.com/questions/9655362/localdb-deployment-on-client-pc – Steve Jan 10 '21 at 11:33
  • 1
    If you use the `.mdf` file - even if "only locally" - you **must** install some form of SQL Server - there's no way to "just copy over the debug folder" and be done with it. In your case: you need to **at least** install SQL Server Express LocalDB (with a compatible version to yours) on the other person's computer, before your app can use the `.mdf` file included – marc_s Jan 10 '21 at 11:43
  • So here's what I found, on this project I have created service-based database stored all the data in it, connected all the forms with the filepath specified above, how can I remodify it for a SQL Server Express LocalDB step-by-step and implement it to a client pc? From finding which server to install to what filepath to use in the connections, what to modify exactly? If there a tutorial for this situation exactly, please send the reference, I can't seem to find what can help me. – Linascts Jan 10 '21 at 13:32
  • Or, if you won't be sharing data with any1 else, you can just save files to disk directly. Serialize to binary file, or to XML/CSV/JSON - depends on the needs. This way you won't be bothered with installing such system (if the app is small). – Tatranskymedved Jan 10 '21 at 16:21

1 Answers1

-1

Use SQL Server (MSSQL), it is just that simple.

Eric Garza
  • 34
  • 3