简体   繁体   English

C ++从Linux访问SQL Server

[英]C++ Access to SQL Server from Linux

I need to write some data to SQL Server database from Linux in C++. 我需要在C ++中从Linux向SQL Server数据库写一些数据。

I found this sqlapi.com 我找到了这个sqlapi.com

But I think, at first ODBC driver has to be installed and has to work. 但我认为,首先必须安装ODBC驱动程序并且必须工作。

I folowed this adminlife.net/allgemein/mssql-zugriff-unter-debian-etch-mit-unixodbc-und-freetds/ or this http://b.gil.megiteam.pl/2009/11/linux-odbc-to-mssql/ 我以下是adminlife.net/allgemein/mssql-zugriff-unter-debian-etch-mit-unixodbc-und-freetds/或http://b.gil.megiteam.pl/2009/11/linux-odbc-to -mssql /

But it didn't work. 但它没有用。 The port 1433 seems to be closed ($ sudo nmap -PN -sU -p 1433 192.168.56.101 -> port "filtered") 端口1433似乎已关闭($ sudo nmap -PN -sU -p 1433 192.168.56.101 - > port“filtered”)

isql -v sqlexpress sa -> wait with no response or get "couldn't connect to sql" isql -v sqlexpress sa - >等待没有响应或得到“无法连接到sql”

From other PC with Windows I have no problem to write data in SQL Server, so server should be right configured to remote access. 从其他带有Windows的PC我在SQL Server中写入数据没有问题,因此服务器应该正确配置为远程访问。

Any ideas? 有任何想法吗?

Here are the links I bookmarked concerning that topic, hope it can help you: 以下是我为该主题添加书签的链接,希望它能为您提供帮助:

It was some time ago, but basically what I remember is: 这是一段时间以前,但基本上我记得的是:

You have to create an entry for the particular MSSQL driver you have in a file named /etc/odbcinst.ini . 您必须在名为/etc/odbcinst.ini的文件中为特定的MSSQL驱动程序创建条目。 Then, for each MSSQL server, you have to create an entry (or DSN ), either globaly in /etc/odbc.ini , or user-local, in $HOME/.odbc.ini . 然后,对于每个MSSQL服务器,您必须在$ HOME / .odbc.ini中的/etc/odbc.ini或user-local中创建一个条目(或DSN )。

Some names I used might differ (and I don't have acces to my Linux box right now to check) but you got the general idea. 我使用的一些名称可能有所不同(我现在没有访问我的Linux盒子来检查),但你有了一般的想法。

Once you did that, isql -d should connect succesfully to the database. 一旦你这样做, isql -d应该成功连接到数据库。 If so, then using the C/Linux API for ODBC should be a piece of cake. 如果是这样,那么使用C / Linux API for ODBC应该是小菜一碟。 Tutorials provided in the given links. 给定链接中提供的教程。

FreeTDS is what you want. FreeTDS就是你想要的。 "FreeTDS is a set of libraries for Unix and Linux that allows your programs to natively talk to Microsoft SQL Server and Sybase databases." “FreeTDS是一套适用于Unix和Linux的库,允许您的程序本地与Microsoft SQL Server和Sybase数据库通信。”

http://www.freetds.org http://www.freetds.org

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM