Re: Strings again :(
On Jan 8, 12:31 pm, "David Webber" <d...@musical-dot-demon-dot-co.uk>
wrote:
"hamishd" <Hamish.D...@gmail.com> wrote in message
news:dc1f26c5-6e3e-435a-9219-af0c908f09de@s9g2000prg.googlegroups.com...
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 *'"
If you have TCHAR szBuf[2001] this should not happen.
In a UNICODE build TCHAR is WCHAR and teh function call is to SQL...W(..)
In a non-UNICODE build it is CHAR and SQL....A().
Are you sure you have used TCHAR consistently?
This is the entire function:
// Get the name of the Excel-ODBC driver
void CSpreadSheet::GetExcelDriver()
{
char szBuf[2001];
WORD cbBufMax = 2000;
WORD cbBufOut;
char *pszBuf = szBuf;
// Get the names of the installed drivers ("odbcinst.h" has to be
included )
if(!SQLGetInstalledDrivers(szBuf,cbBufMax,& cbBufOut))
{
m_sExcelDriver = "";
}
// Search for the driver...
do
{
if( strstr( pszBuf, "Excel" ) != 0 )
{
// Found !
m_sExcelDriver = CString( pszBuf );
break;
}
pszBuf = strchr( pszBuf, '\0' ) + 1;
}
while( pszBuf[1] != '\0' );
}
The error message is the same regardless of whether or not i use
TCHAR, WCHAR, or char.