找不到 Microsoft.SqlServer.ConnectionInfo.dll 程序集文件?
我正在尝试仅使用 C# 代码动态获取数据库表结构,如下所示:
using Microsoft.SqlServer.Management.Common;
using Microsoft.SqlServer.Management.Smo;
public class LoadStuff
{
...
public void LoadDatabase(string vDatabaseName)
{
using (var vSqlConnection = new SqlConnection(DatabaseConnectionString))
{
var vConnection = new ServerConnection(vSqlConnection);
var vServer = new Server(vConnection);
var vDatabase = vServer.Databases[vDatabaseName];
var vTables = vDatabase.Tables;
}
}
}
但是,我也找不到 .dll 文件来添加引用。我使用的是 Visual Studio 2010 专业版。有什么建议吗?
I'm trying to dynamically get a databases Table structure using only C# code as follows:
using Microsoft.SqlServer.Management.Common;
using Microsoft.SqlServer.Management.Smo;
public class LoadStuff
{
...
public void LoadDatabase(string vDatabaseName)
{
using (var vSqlConnection = new SqlConnection(DatabaseConnectionString))
{
var vConnection = new ServerConnection(vSqlConnection);
var vServer = new Server(vConnection);
var vDatabase = vServer.Databases[vDatabaseName];
var vTables = vDatabase.Tables;
}
}
}
However, I cannot find the .dll file to add a reference too. I'm using Visual Studio 2010 Professional. Any suggestions?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
它位于我的计算机上的 c:\program files\microsoft sql server\xxx\sdk\assemblies 中。其中 xxx 是 SQL Server 版本号(90 或 100)。不知道它是如何到达那里的。
更新:它已被 SMO 取代(SQL Server 管理对象)。 Nuget 包位于此处。请点击第一个链接获取文档。
It is located in c:\program files\microsoft sql server\xxx\sdk\assemblies on my machine. Where xxx is the SQL Server version number (90 or 100). Not sure how it got there.
UPDATE: it has been replaced by SMO (SQL Server Management Objects). The Nuget package is here. Follow the first link for documentation.
请右键单击您的解决方案并选择“添加引用”,然后选择以下 dll:
Please right click your solution and select 'Add reference' and then select the following dlls:
在我的计算机上,它位于
C:\Program Files (x86)\Microsoft SQL Server\100\SDK\Assemblies
。作为替代方案,您还可以从 SQL Server 下载独立安装 2008 或 2008 R2 功能包。有单独的 x86 和 x64 安装包可用。On my machine it is located at
C:\Program Files (x86)\Microsoft SQL Server\100\SDK\Assemblies
. As an alternative, you can also download the standalone installation from the SQL Server 2008 or 2008 R2 feature packs. There are individual x86 and x64 installation packages available.