SQLite Forum

Spanish characters in SQLITE
Login
Hello,
I am trying to use the sqlite dll with c++ compiler.
My problem is that the Spanish characters are not correctly insert in tables and not correctly retrieve in the select statement.
If somebody can help me.
Thanks a lot,
Olivier
The connexion is done with the function  :

Rc = sqlite3_open_v2(DataBase, &ConnexioLocal,SQLITE_OPEN_READWRITE,NULL);

And the select  :

char **SelectDirecte(char *SelectText,unsigned int  *NbColumnes)
{
  const unsigned char * valChar;
  int Rc;
  int type;
  int colCount;
  UnicodeString Result;

  if (Columnes != NULL)
  {
	delete [] Columnes;
	Columnes = NULL;
  }

  Rc = sqlite3_prepare(ConnexioLocal,SelectText,-1,&stmt,NULL);
  if( Rc != SQLITE_OK )
  {
	swprintf(Msg, 100, L"%hs", sqlite3_errmsg(ConnexioLocal));
	MessageBox(AplicacioHandle,Msg,L"DataBase",MB_ICONERROR);
	return NULL;
  }

  Rc = sqlite3_step(stmt);

  if ((Rc != SQLITE_DONE && Rc != SQLITE_OK))
  {
	colCount = sqlite3_column_count(stmt);
	Columnes = new char*[colCount];
	*NbColumnes = colCount;
  }

  if (Rc != SQLITE_DONE && Rc != SQLITE_OK)
  {
	for (int colIndex = 0; colIndex < colCount; colIndex++)
	{
		type = sqlite3_column_type(stmt, colIndex);
		const char * columnName = sqlite3_column_name(stmt, colIndex);
		if (type == SQLITE_INTEGER * 100)
		{
			sprintf(valChar, "%f\0",sqlite3_column_int(stmt, colIndex));
			Columnes[colIndex] = new char[strlen(valChar)+1];
			strcpy(Columnes[colIndex],valChar);
		}
		else if (type == SQLITE_FLOAT)
		{
			sprintf(valChar, "%f\0",sqlite3_column_double(stmt, colIndex));
			Columnes[colIndex] = new char[strlen(valChar)+1];
			strcpy(Columnes[colIndex],valChar);
		}
		else if (type == SQLITE_TEXT || type == SQLITE_INTEGER)
		{
			valChar = (const char*)(sqlite3_column_text16(stmt, colIndex));
			valChar = sqlite3_column_text(stmt, colIndex);
			Columnes[colIndex] = new char[strlen(valChar)+1];
			strcpy(Columnes[colIndex],valChar);
		}
		else if (type == SQLITE_BLOB)
		{
			printf("columnName = %s,BLOB", columnName);
		}
		else if (type == SQLITE_NULL)
		{
			printf("columnName = %s,NULL", columnName);
		}
	}
  }
  else
  {
	return NULL;
  }

  Rc = sqlite3_finalize(stmt);

  return(Columnes);
}