如何将本地(服务)数据库连接到C#

问题描述:

我需要在本地数据库之间建立连接的帮助,我选择了服务数据库,因为它的扩展名为.mdf.

我尝试连接,好像我尝试连接MS访问文件一样,但未连接.

我应该尝试连接访问数据库文件或SQL文件之类的本地数据库吗?

I need help in creating connection between local database, i selected service database because it had .mdf extension.

I tried to connect as if I try to connect MS access file but its not getting connected.

Should I try connecting local database like access database file or SQL file?

您需要将其附加到SQL Server实例,然后使用SQL Server客户端连接器.如果您的数据库不是太大(4GB或10GB,取决于版本,我忘记了),SQL Server Express应该可以的.
You''ll need to attach that to an SQL Server instance, and use the SQL server client connectors. SQL Server Express should be okay, if your DB is not too large (4GB or 10 GB, depending on versions, I forget)