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

时间:2019-03-06 10:48:13

标签: sql-server visual-studio-code ubuntu-18.04 sql-server-2017

我刚刚在Ubuntu 18.10计算机上安装了适用于Linux的MSSQL 2017和适用于Linux的Visual Studio代码。 两种安装均成功,但是我无法从Visual Studio连接到数据库。

我有以下正在运行的驱动程序:

$ 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.

目前,我已被锁定,无法继续操作。

有人在运行解决方案吗?

1 个答案:

答案 0 :(得分:1)

仅当您计划进行unixodbc-dev开发时才需要unixodbc-dev(数据库连接不需要)。我想您可以在这里省略它以避免混淆。

msodbcsql和msodbcsql17是不同的程序包。 msodbcsql(用于SQL Server的MS ODBC驱动程序13)甚至在Ubuntu 18.10上也不可用。

问题的关键是错误消息:

  

E:无法纠正问题,您拿着损坏的包裹。

您需要卸下损坏的包装上的货箱。首先,我会尝试专门安装msodbcsql17:

sudo apt-get install msodbcsql17

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