问题
I'm using SQLite so it's only a file, not a server, but here's the plan:
Install the application + the physical .sqlite file on a machine and on another machine over the network, let the other user connect to the .sqlite file.
So I'd have to share that folder and give it permissions to allow everyone to read and write from it.
Here's my App.config:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<connectionStrings>
<add name="ColegioMentorEntities" connectionString="metadata=res://*/Repositories.ColegioMentor.csdl|res://*/Repositories.ColegioMentor.ssdl|res://*/Repositories.ColegioMentor.msl;provider=System.Data.SQLite;provider connection string="data source=C:\Users\Sergio\Desktop\ColegioMentor.sqlite"" providerName="System.Data.EntityClient" /></connectionStrings>
<startup useLegacyV2RuntimeActivationPolicy="true">
<supportedRuntime version="v4.0" />
</startup>
</configuration>
It seems I CAN change the connection string! Great! But how do I reference a networked location in a string?
回答1:
As suggested here, you may want to consider using something like MySQL if you need to support more than a single user, due to potential corruption issues that can arise when you access SQLite concurrently.
Though SQLite does support concurrent access, there are several caveats that you can read about on their FAQ (see items 5 and 6).
From that page:
sharing an SQLite database between two or more Windows machines might cause unexpected problems
回答2:
The first thing that comes to mind is a standard UNC path, like:
\\ServerName\ShareName\Database.sqlite
I hope this helps!
回答3:
To answer your question about the ShareName, it would be the shared name of the shared folder, as shown in the properties dialog > Shared Tab > share name, not the windows explorer folder name (assuming you're using windows).
来源:https://stackoverflow.com/questions/4906912/how-do-i-give-a-connection-string-to-a-server-on-a-network