ubuntu 安裝freetds
大家可能會說,安裝freetds的博客到處都是,為何還要多此一舉呢,主要是因?yàn)楣P者在安裝的過程中遇到了一些問題,這些問題,沒有解決,大家都解決了,或者大家都沒有遇到筆者的問題吧,或許,所以,在這里,我寫下,自己的困惑
sudo?cp?-r?/home/john/Desktop/freetds-0.91/?/usr/soft/
我把freetds的源代碼復(fù)制到/usr/soft下,進(jìn)入到/usr/soft/freetds-0.91盡心安裝,可總是出錯(cuò)
txt2man?not?found? all-recivev?error?127
等等,我的解決辦法是將源代碼復(fù)制在桌面上,然后進(jìn)行安裝,提示成功
這里我們修改配置文件/etc/ld.so.conf文件為
include /etc/ld.so.conf.d/*.conf
/usr/local/freetds/lib? (這是新添加的)
#include#include#include#include#include#includeint?main(void) { ???????char?szUsername[32]?=?"sa"; ???????char?szPassword[32]?=?"rjgc214team"; ???????char?szDBName[32]?=?"IKCExamples"; ???????char?szServer[32]?=?"115.24.160.253";//形式如10.10.11.12:1111 ? ???????//初始化db-library ???????dbinit(); ???????//連接數(shù)據(jù)庫 ???????LOGINREC?*loginrec?=?dblogin(); ???????DBSETLUSER(loginrec,?szUsername);?????? ???????DBSETLPWD(loginrec,?szPassword); ???????DBPROCESS?*dbprocess?=?dbopen(loginrec,?szServer); ???????if(dbprocess?==?FAIL) ???????{ ??????????????printf("ASB>>??????Conect?MS?SQL?SERVER?fail???????n"); ??????????????return?0; ???????} ???????printf("ASB>>??????ConnectEMS?conect?MS?SQL?SERVER?successn"); ?????? ???????if(dbuse(dbprocess,?szDBName)?==?FAIL) ???????{ ??????????????printf("ASB>>??????Open?database?name?failn"); ???????} ???????else ???????{ ??????????????printf("ASB>>??????Open?database?name?successn"); ???????} ?????? ???????//查詢數(shù)據(jù)庫 ???????/*dbcmd(dbprocess,?"select?ID,BeginTime,Description?from?Alarms"); ???????if(dbsqlexec(dbprocess)?==?FAIL) ???????{ ??????????????printf("ASB>>??????Query?Alarms?table?errorn");???? ???????} ?????? ???????DBINT?result_code; ???????char?szID[1024]; ???????char?szBeginTime[1024]; ???????char?szDescription[1024]; ???????int?rows?=?0; ???????while?((result_code?=?dbresults(dbprocess))?!=?NO_MORE_RESULTS){ ??????????????if?(result_code?==?SUCCEED){ ?????????????????????dbbind(dbprocess,?1,?CHARBIND,?(DBINT)0,?(BYTE*)szID); ?????????????????????dbbind(dbprocess,?2,?CHARBIND,?(DBCHAR)0,?(BYTE*)szBeginTime); ?????????????????????dbbind(dbprocess,?3,?CHARBIND,?(DBCHAR)0,?(BYTE*)szDescription); ?????????????????????????????????????????while?(dbnextrow(dbprocess)?!=?NO_MORE_ROWS){??????????????????????? ????????????????????????????printf("ASB>>?????????????ID=%sn",?szID); ????????????????????????????printf("ASB>>?????????????szAid=%sn",?szBeginTime); ????????????????????????????printf("ASB>>?????????????szBeginTime=%sn",?szDescription); ?????????????????????} ??????????????} ???????}*/ ???????//關(guān)閉數(shù)據(jù)庫連接 ???????dbclose(dbprocess); ?????? ???????return?0; }
進(jìn)行編譯鏈接
?gcc?-o?testsybase?SQL.c?-L/usr/local/freetds/lib?-lsybdb
執(zhí)行即可
john@john-OptiPlex-780:~/Documents/SQL$?./testsybase ASB>>??????ConnectEMS?conect?MS?SQL?SERVER?success ASB>>??????Open?database?name?success
提示成功
方法2:直接執(zhí)行 sudo? apt-get install freetds-bin 自動安裝也是可以的