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

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

我刚刚在 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 安装 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

尝试执行以下命令:

sudo apt-get install libodbc1 unixodbc msodbcsql mssql-tools unixodbc-dev

或者

为了强制“ apt-get install”回答“ ”可能出现的Yes任何“ ”问题,请执行以下操作:Are you sure you want to install this package? [Y/n]

sudo apt-get install libodbc1 unixodbc msodbcsql mssql-tools unixodbc-dev -y

如果有帮助的话请记得留下反馈。

答案2

我也遇到了这个问题。

事实证明,msodbcsql 依赖于 unixodbc(如您所指出的),而 unixodbc 又依赖于 libodbc1。我必须先安装这些。

sudo apt-get install libodbc1 
sudo apt-get install unixodbc
sudo apt-get install msodbcsql

# You can now install the package you actually want

sudo apt-get install mssql-tools unixodbc-dev

希望有所帮助。

答案3

您可能还必须安装libcurl3。我遇到了这个错误,我使用以下命令解决了它:

sudo apt-get install libcurl3 -y

相关内容