我正在使用LINQ to SQL与Microsoft SQL 服务器数据库文件(SqlClient)作为数据源。 db文件是在添加连接(Database Explorer - > Add Connection)时由Visual Studio 2010创建的。 使用这种方法,我无法创建一个数据库与SQL身份验证,所以我使用Windows身份验证。无法连接到附加的SQL数据库
编辑:请注意,它不是连接到数据库,它是到数据库文件的连接。
1)是否可以使用sql身份验证创建数据库文件? (我认为这是问题的根源)。
2)连接在我的电脑下在不同的帐号下工作正常。但是,在其他计算机上运行该版本会导致抛出异常。
异常详细信息:
System.Data.SqlClient.SqlException (0x80131904): A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: SQL Network Interfaces, error: 26 - Error Locating Server/Instance Specified)
我已经试过手动设置数据库路径,但我想这不是问题。
我在做什么错?
EDIT2:我使用的连接字符串:
Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\OperatorResults.mdf;Integrated Security=True;Connect Timeout=10;User Instance=True"
AFAIK SqlClient不直接访问SQL Server文件!所以是的你运行SQL Server等 – Yahia
我希望能达到类似于使用sqllite数据库的结果。 我拥有的SQL服务器是与Visual Studio一起安装的。 – grrawr
这是不可能的 - SQLLite是一个“独立的数据库” - 客户端访问文件 - 但SQL Server是真的不同,因为名称表示它是一个SERVER数据库,需要通过服务器进程访问......出了什么问题用你有的SQLLite解决方案? – Yahia