如何为网络上的服务器提供连接字符串? [英] How do I give a connection string to a server on a network?

查看:193
本文介绍了如何为网络上的服务器提供连接字符串?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用SQLite,所以它只是一个文件,而不是服务器,但这是计划:

I'm using SQLite so it's only a file, not a server, but here's the plan:

在网络上的一台计算机和另一台计算机上安装应用程序+物理.sqlite文件,让其他用户连接到.sqlite文件.

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.

这是我的App.config:

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=&quot;data source=C:\Users\Sergio\Desktop\ColegioMentor.sqlite&quot;" 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?

推荐答案

如建议的此处,如果需要同时支持多个用户,则可能需要考虑使用MySQL之类的东西,因为同时访问SQLite时可能会出现潜在的损坏问题.

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.

尽管SQLite确实支持并发访问,但是您可以在其常见问题上阅读一些警告. (请参阅第5和第6项).

Though SQLite does support concurrent access, there are several caveats that you can read about on their FAQ (see items 5 and 6).

在该页面上:

在两个之间共享一个SQLite数据库 或更多Windows机器可能导致 意外的问题

sharing an SQLite database between two or more Windows machines might cause unexpected problems

这篇关于如何为网络上的服务器提供连接字符串?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆