在sqlconnect ODBC函数中指定DSN [英] Specifying DSN in sqlconnect ODBC function
问题描述
Unicode构建。
我现在正在尝试
std :: wstring dsn(L dailyworkbook);
rc = SQLConnectW(ConHandle,(SQLWCHAR *)dsn.c_str(),dsn.length(),(SQLWCHAR *)L,SQL_NTS,(SQLWCHAR *)L,SQL_NTS) ;
程序编译但运行时访问违规。如果我用3/10/3000(任何疯狂的值)替换dsn.length(),则不会发生违规,但ODBC报告无效的字符串或缓冲区长度。如果我用SQL_NTS / length()替换dsn.length(),我会得到访问冲突。
我尝试过:
在Visual Studio中调试。自昨天以来,我一直在Codeproject上继续这样做。
Unicode build.
I am now trying
std::wstring dsn(L"dailyworkbook");
rc = SQLConnectW(ConHandle, (SQLWCHAR*)dsn.c_str(), dsn.length(), (SQLWCHAR*)L"", SQL_NTS, (SQLWCHAR*)L"", SQL_NTS);
The program compiles but run time access violation. If I replace dsn.length() with 3/10/3000(any crazy value) the violation doesnt occur, but ODBC reports invalid string or buffer length. If I replace dsn.length() with SQL_NTS/length() whatever, i get the access violation.
What I have tried:
Debugging in Visual studio. Also been pursuing this on Codeproject since yesterday.
推荐答案
我找到了一个示例这里和sergio使用SQL_NTS而不是尝试为DSN指定特定长度。你试过了吗?
我对此有疑问,我已经离开了C ++很长一段时间了。有必要指定各种各样的W?如果你使用SQLConnect那么它会使用适合构建的任何变体,不是吗?
HTH,
Mike
I found a sample here and sergio is using SQL_NTS instead of trying to specify a specific length for the DSN. Have you tried that?
I have a question about this, I've been out of C++ for a long time. It is necessary to specify the W variety of everything? If you use SQLConnect then it would use whatever variant is appropriate for the build, no?
HTH,
Mike
这篇关于在sqlconnect ODBC函数中指定DSN的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!