Can't find Microsoft.SqlServer.ConnectionInfo.dll assembly file?
Asked Answered
B

3

19

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?

Bilection answered 24/8, 2010 at 12:28 Comment(0)
Q
27

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.

Quadrivium answered 24/8, 2010 at 12:35 Comment(3)
Found it, thanks. Now, when an end user runs this, is this referenced .dll file going to be bundled into my software?Bilection
Doubtful. Set Copy Local to True so it is copied to your build directory, ready to be included in your Setup project.Quadrivium
What do I need install to get assemblies?Pl
M
7

Please right click your solution and select 'Add reference' and then select the following dlls:

  • C:\WINDOWS\assembly\GAC_MSIL\Microsoft.SqlServer.SMO
  • C:\WINDOWS\assembly\GAC_MSIL\Microsoft.SqlServer.ConnectionInfo
  • C:\WINDOWS\assembly\GAC_MSIL\Microsoft.SqlServer.Management.Sdk.sfc
Maren answered 19/7, 2011 at 11:2 Comment(1)
This didn't work for me, but was a good hint. I ended up installing these via NuGet. Right click on Refernces, Manage NuGet Packages, search for Microsoft.sqlserver. then install the Microsoft.SqlServer.* DLL's of interest. (Feb 2016, Visual Studio 2015 Pro Update 1)Banded
H
0

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.

Heeheebiejeebies answered 24/8, 2010 at 12:51 Comment(1)
Do I need install Sql Server 2008 Express ?Pl

© 2022 - 2024 — McMap. All rights reserved.