what i need to do is to execute an SQL query:
wstring query = ( L "INSERT INTO database...........;
then i execute this:
CHECK( SQLExecDirectA( hStmt, query, SQL_NTS ), "execute query" );
but it doesn't compile, because the variable query must be an SQLCHAR otherwise function SQLExecDirectA wont work.
can anyone help please?
thanks!
std::wstring
(or std::string
) can not be converted directly to wchar_t *
(or char *
). You have to use e.g. query.c_str()
to get a character pointer - Some programmer dude 2012-04-05 06:05
The function you are trying to call is called SQLExecDirect. (Nearly) all the functions in the winapi exist in two version - a ascii version and a wide version. Depending on your project settings (Multibyte character set/Unicode) SQLExecDirect is a define to either SQLExecDirectA or SQLExecDirectW (with SQLExecDirectA beeing the ascci version and SQLExecDirectW beeing the wide version).
The SQLExecDirectA means your are explicitely calling the ascii version with a wide string as parameter. Try calling SQLExecDirectW or SQLExecDirect if you want to use wide strings.