无法连接 Microsoft SQL-Server 和 Visual Studio 代码

Unable to connect Microsoft SQL-Server and Visual Studio code

我刚刚在 Ubuntu 18.10 机器上为 linux 安装了 MSSQL 2017 并为 linux 安装了 Visual Studio 代码。 两个安装都成功了,但是我无法从 visual studio 连接到数据库。

我有以下 运行ning 驱动程序:

$ odbcinst -j

    unixODBC 2.3.7
    DRIVERS............: /etc/odbcinst.ini
    SYSTEM DATA SOURCES: /etc/odbc.ini
    FILE DATA SOURCES..: /etc/ODBCDataSources
    USER DATA SOURCES..: /home/neo4j/.odbc.ini
    SQLULEN Size.......: 8
    SQLLEN Size........: 8
    SQLSETPOSIROW Size.: 8

但是,当我尝试安装时

$ sudo apt-get install mssql-tools unixodbc-dev

我收到以下错误:

Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.
The following information may help to resolve the situation:

The following packages have unmet dependencies:
 mssql-tools : Depends: msodbcsql17 (>= 17.3.0.0) but it is not going to be installed
               Depends: msodbcsql17 (< 17.4.0.0) but it is not going to be installed
 unixodbc-dev : Depends: unixodbc (= 2.3.7)
E: Unable to correct problems, you have held broken packages.

经过大量谷歌搜索后,我找到了很多建议,但它们没有 运行,例如尝试删除 msodbcsql 和 unixodbc

$ sudo apt-get remove msodbcsql

Reading package lists... Done
Building dependency tree       
Reading state information... Done
Package 'msodbcsql' is not installed, so not removed
0 upgraded, 0 newly installed, 0 to remove and 1 not upgraded.

此时我已锁定,无法继续。

有人 运行ning 解决方案吗?

如果您计划进行 unixodbc-dev 开发,则只需要 unixodbc-dev(数据库连接不需要)。我猜您可以将其省略以避免混淆。

并且 msodbcsql 和 msodbcsql17 是不同的包。 msodbcsql(SQL 服务器的 MS ODBC 驱动程序 13)在 Ubuntu 18.10 上什至不可用。

你的问题的关键是错误信息:

E: Unable to correct problems, you have held broken packages.

您需要取消对破损包裹的保留。首先,我会尝试专门安装 msodbcsql17:

sudo apt-get install msodbcsql17

如果您仍然遇到错误,您可以采取其他步骤来尝试解决保留包裹的问题: https://askubuntu.com/a/223267