问题描述
我已经为 RHEL 6 安装了以下 ODBC 驱动程序。
*
*sudo su curl https://packages.microsoft.com/config/rhel/6/prod.repo > /etc/yum.repos.d/mssql-release.repo
exit
sudo yum remove unixODBC-utf16 unixODBC-utf16-devel #to avoid conflicts
sudo ACCEPT_EULA=Y yum install msodbcsql
optional: for bcp and sqlcmd
sudo ACCEPT_EULA=Y yum install mssql-tools
echo 'export PATH="$PATH:/opt/mssql-tools/bin"' >> ~/.bash_profile
echo 'export PATH="$PATH:/opt/mssql-tools/bin"' >> ~/.bashrc source ~/.bashrc
optional: for unixODBC development headers sudo yum install unixODBC-devel
https://docs.microsoft.com/en-us/sql/connect/odbc/linux-mac/installing-the-microsoft-odbc-driver-for-sql-server?view=sql-server-ver15*
我有一个连接到 sql Server 2016 的 C++ 命令行应用程序。 使用odbc驱动,连接服务器成功。但是,当调用 bcp_init 时,应用程序会崩溃。
以下是代码片段。
**retcode = bcp_init(m_hDbc,"EMPLOYEE_TABLE",NULL,DB_IN);**
当我传递 NULL 而不是 EMPLOYEE_TABLE 时,应用程序不会崩溃,但随后我无法将数据批量加载到表中,因为随后的 bcp 调用失败。
以下是 GDB 故障转储堆栈,如果有帮助的话。
3 LoadStringW (hInstance=0x0,uID=40031,lpBuffer=0x7fff98c962b0 L"",nBufferMax=30) at sql/Ntdbms/sqlncli/xplat/src/Resources.cpp:678
root_dir = <value optimized out>
str = <value optimized out>
idx = <value optimized out>
lpDest = <value optimized out>
rll = 0x0
size = <value optimized out>
copy_len = <value optimized out>
lpSrc = <value optimized out>
nBackslashR = <value optimized out>
4 0x00007f26677d7520 in LoadStringA (hInstance=Unhandled dwarf expression opcode 0xf3)
at sql/Ntdbms/sqlncli/xplat/src/Resources.cpp:652
wide_resource = L'\000\000' <repeats 4288 times>"\xb35a,\u0479\000\xcd6d\x66ef\u7f26\000\000\000\000\000\000\000\000\xd6b8\u0475\000\xdc96\x66ef\u7f26\000\000\000\000\xa6a0\x98c9\u7fff\xbcb\x66e9\u7f26\000\000\000\000\000\000\000\000\000\000\000\000---Typ---Type <return> to continue,or q <return> to quit---
\000\000\000\000\xc560\x671e\u7f26\xb198\u0479\000\xb198\u0479\000\xced0\u047a\000\xffff\xbffb\u07f1\xa660\x98c9\u7fff\000\000\000\000\000\000\000\000\120\127D\142\141\163e",'\000\000' <repeats 11 times>"\000,\155\100\164\162\151\170\061\062\063\000\137\163\165\160\160\157\162t\123\121\114\040\123\145\162\166\145r",'\000\000' <repeats 389 times>"\432,\u0242\000\xcd6d\x66ef\u7f26\000\000\000\000\000\000\000\000\xa8b8\u022d\000\xdc96\x66ef\u7f26\000\000\000\000\xade0\x98c9\u7fff\xbcb\x66e9\u7f26\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\xc560\x671e\u7f26\x6968\u023e\000\x6968\u023e\000\x2920\u0243\000\xffff\xbffb\u07f1\xada0\x98c9\u7fff\000\000\000\000\000\000\000\000\120\127D\142\141\163e",'\000\000' <repeats 389 times>"\x7d1a,\u0177\000\xcd6d\x66ef\u7f26\000\000\000\000\000\000\000\000\xe0f8\u0134\000\xdc96\x66ef\u7f26\000\000\000\000\xb520\x98c9\u7fff\xbcb\x66e9\u7f26\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\xc560\x671e\u7f26\x9878\u0134\000\x9878\u0134\000\x9880\u0138\000\xffff\xbffb\u07f1\xb4e0\x98c9\u7fff\000\000\000\000\000\000\000\000\120\127D\142\141\163e",'\000\000' <repeats 497 times>"\xbf0a,\u0134\000\xcd6d\x66ef\u7f26\000\000\000\000\000\000\000\000\xe0f8\u0134\000\xdc96\x66ef\u7f26\000\000\000\000\xbe10\x98c9\u7fff\xbcb\x66e9\u7f26\xe0da\u0134\000\xcd6d\x66ef\u7f26\000\000\000\000\000\000\000\000\x3d68"...
r = <value optimized out>
`5 0x00007f2667717966 in sqlLoadStringA (lpdbc=0x2432920,pwszTableName=0x7fff98ca6370` L"\115\101\122\123\137\104\117\103\137\123\124\---Type <return> to continue,or q <return> to quit---
101\124\125",<incomplete sequence \123>,pwszFilePath=0x0,pwszErrorFilePath=0x0,iDirection=Unhandled dwarf expression opcode 0xf3
) at sql/Ntdbms/sqlnclI/Odbc/sqlcprot.h:1402
No locals.
6 BCP_init (lpdbc=0x2432920,pwszTableName=0x7fff98ca6370 L"\115\101\122\123\137\104\117\103\137\123\124\101\124\125",iDirection=Unhandled dwarf expression opcode 0xf3
)
at sql/Ntdbms/sqlnclI/Odbc/sqlcbcp.cpp:3355
retcode = 0
pbcp = <value optimized out>
7 0x00007f26677d1f84 in ExportImp::bcp_initW (hdbc=0x23623b0,table=0x7fff98ca6370 L"\115\101\122\123\137\104\117\103\137\123\124\101\124\125",file=0x0,errfile=0x0,direction=1)
at sql/Ntdbms/sqlnclI/Odbcbcp/bcpstub.cpp:553
lpdbc = 0x2432920
retcode = <value optimized out>
hDriver = 0x12e0060
direction = 1
errfile = 0x0
file = 0x0
table = 0x7fff98ca6370 L"\115\101\122\123\137\104\117\103\137\123\124\101\124\125",<incomplete sequence \123>
---Type <return> to continue,or q <return> to quit---
hdbc = 0x23623b0
8 0x00007f26677d2095 in bcp_initA (hdbc=0x23623b0,table=0x7fff98ca6370 "M",direction=1)
at sql/Ntdbms/sqlnclI/Odbcbcp/bcpstub.cpp:514
szTable = L"\115\101\122\123\137\104\117\103\137\123\124\101\124\125S\x30a0\u023e\000\xb3f3\x66ee\u7f26\x6450\x98ca\u7fff\x6dd0\u98ca\000\x9f00\u0466\000\xab1c\x9e07\070\000\xffff\xffff\xffff\xffff\012\000\000\000\x6d50\x98ca\u7fff\x9fa0\u0466\000\011\000\000\000\x6d50\x98ca\u7fff\x6450\x98ca\u7fff\x6dd0\x98ca\u7fff\x9f00\u0466\000\000\216\000\000\011\000\000\000\x6dd0\x98ca\u7fff\x6dc0\x98ca\u7fff\t\000\000\xa1f0\u024f\000\x6d50\x98ca\u7fff\x6db0\x98ca\u7fff\567\216\000\000\x326e\x3230\x3130\x3332\061\x98ca\u7fff\x4098\u02d0\000\567\216\000\000\x3032\x3032\x3231\x3133\x6b00\x98ca\u7fff\b\000\000\x6c90\x98ca\u7fff\xf77f\235\000\000\x4047\x9e04\070\000\x6ba0\x98ca\u7fff\x6b90\x98ca\u7fff\x6bb0\x98ca\u7fff\x6ba0\x98ca\u7fff\b\000\000\x6cd0\x98ca\u7fff\030\000\060\000\x6890\x98ca\u7fff\x67d0\x98ca\u7fff\x6bd0\x98ca\u7fff\030\000\060\000\x68b0\x98ca\u7fff\x67f0\x98ca\u7fff\x4047\x9e04\070\000\xf7f0\235\000\000\000\000\000\000\x4a2d¡\000\x6af8\x98ca\u7fff\000\000\000\000\000\000\000\000\x6aec\x98ca\u7fff\000\000\000\000\x6ac0\x98ca\u7fff\x6b18\x98ca\u7fff\xf7e7\235\000\000\x6b38\x98ca\u7fff\xff00\xffff\xffff\xffff\000\000\000\000\x6b2c\x98ca\u7fff\x6b48\x98ca\u7fff\000\000\000\000\x6b68\x98ca\u7fff\xff00\xffff\x6a66\x98ca\x65f0\u98ca\000\xa380\x98ca\u7fff\x62a0\u022d\000\xa380\x98ca\u7fff\xb3f3\u66ee\000\xa3a0\x98ca\u7fff\x62a0\u022d\000\xa3a0\x98ca\u7fff\xb3f3\x66ee\u7f26\u03ff\000\000\x83c0\x98ca\u7fff\x68c0\x98ca\u7fff\xf632\x9e06\070\000\x8001\xfbad\u7fff\x68c0\x98ca\u7fff\x68c0\x98ca\u7fff\x68c0\x98ca\u7fff\x68c0\x98ca\u7fff\x68e1\x98ca\u7fff\x6cbf\x98ca\u7fff\x68c0\x98ca\u7fff\x6cbf\x98ca\u7fff\000\000\000\000\000\000\000\000\000\000\000\000\000\000"
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)