Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » Community » Newbie corner » MSSQL and codepage
MSSQL and codepage [message #49473] Thu, 15 February 2018 17:39
Giorgio is currently offline  Giorgio
Messages: 218
Registered: August 2015
Experienced Member
Hi there,
this seems to be a never ending story Sad

I have an application that does the following:
1. Read data from a text file (encoding Windows1252)
2. Store them in a sqlite db (encoding utf8)
3. Take off data from sqlite and entering them into a MS SQL server (encoding Latin1 that should be mostly compatible with Windows1252)

(I can not avoid point 2. because when in sqlite data are somehow modified)

First problem was the encoding in the file and the fact that I mixed in my application std::string and Upp::String. Now that is fixed thanks to the forum, and my application uses Upp::String everywhere. This is the thread.

Now the problem is entering the data in MS SQL; this is the method entering data:

struct myS_Table{
	int Id;
	int Row;
	String Description;
};

...

bool ImportData::InsertBody(myS_Table record)
{
	Sql sql(mssql);
	sql.ClearError();

	try { sql * Insert(My_Table)
					(My_Id, record.Id)
					(My_Row, record.Row)
					(My_Description, record.description);
				return true;
	} catch(SqlExc) {
		ErrorOK(t_("Failed adding data to the database due to the following error: ") + SQL.GetLastError());
		return false;
	}
	return true;
}


The problem is that record.Description is utf8 and if it contains strange characters (e.g. Ö) in the db is entered gibberish instead of the proper character.
At the moment I use these functions to convert from utf8 to windows1252, but I do not like it for several reason, first of them is that Windows1252 is not completely the same to Latin1, and for specific cases I found up to now is ok using Win1252, but maybe in future I will have problems.
Is there a way to tell Upp to use Latin1 charset when issuing SQL commands?
Thanks,
Gio
 
Read Message
Previous Topic: From std::string to String
Next Topic: ArrayMap / Polymorphism question
Goto Forum:
  


Current Time: Thu Mar 28 23:04:50 CET 2024

Total time taken to generate the page: 0.02603 seconds