Re: Strings again :(

Tech-Archive recommends: Fix windows errors by optimizing your registry



All SQL documentation that specifies LPSTR/LPCSTR is erroneous. The header files for all
the SQL APIs define -W versions that take LPWSTR/LPCWSTR parameters. In fact, in a couple
cases the documentation erroneously specifes an LPSTR when the header says LPCSTR or an
LPCSTR when the header says LPSTR.

I have now added all of these to my Errors and Omissions document.
joe
On Wed, 7 Jan 2009 15:57:14 -0800, "Tom Serface" <tom@xxxxxxxxxxxxxxxxxxxx> wrote:

The help for SQLGetInstalledDrivers says:

BOOL SQLGetInstalledDrivers(
LPSTR lpszBuf,
WORD cbBufMax,
WORD * pcbBufOut);

Indicating that you have to use a char buffer, but it looks like it's
calling a W flavor which seems odd.... Even the error you're getting
doesn't make sense because the first You might try something like:

TCHAR szBuf[2001];
WORD cbBufMax = 2000 * sizeof(TCHAR);
WORD cbBufOut;
LPTSTR *pszBuf = szBuf; // Not sure what you're using this for exactly
maybe you intended to pass this into the function instead?

This link might have something useful for you. I admit I haven't used this
function so I'm sort of just guessing here.

http://bugs.mysql.com/bug.php?id=35776

Tom


"hamishd" <Hamish.Dean@xxxxxxxxx> wrote in message
news:dc1f26c5-6e3e-435a-9219-af0c908f09de@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Hi - sorry this is my 3rd question recently. I'm having trouble with
strings and characters and unicode in general; can anybody suggest a
good article to read which explains the basics?

My project is _UNICODE defined. However, a file I got from codeproject
is not. Their code is below, but it cannot compile.

char szBuf[2001];
WORD cbBufMax = 2000;
WORD cbBufOut;
char *pszBuf = szBuf;

SQLGetInstalledDrivers(szBuf,cbBufMax,& cbBufOut);

I would have thought changing the char's to TCHAR's would fix..
however, I still get "error C2664: 'SQLGetInstalledDriversW' : cannot
convert parameter 1 from 'char [2001]' to 'unsigned short *'"

Incidentally, I am trying to read data from an excel spread***, and
trying the CSpread*** class from
http://www.codeproject.com/KB/database/cspread***.aspx.
Joseph M. Newcomer [MVP]
email: newcomer@xxxxxxxxxxxx
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm
.


Quantcast