Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
Good day all,
 
I encountered were strange problem during my work.
When I call stored procedure from JScript (Jscript code is compiled by 3rd party desktop application that uses windows script 5.6) and give it data through parameters it ends up that data stored in database are different based on which localization of microsoft windows i use(eq. czech and fench).
 
We are using SQL server 2008 R2 express as database.
 
Here is Jscript code:
function file_addBinaryData(ProductionProfileID, RowData, create, DB) {
	var connectionstring = "Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=ABN_EXTENSIONS;Data Source=" + DB + ";";
	var sp_file_row = new ActiveXObject("ADODB.Command");
	var ret;
	var conn = new ActiveXObject("ADODB.connection");
	conn.ConnectionString = connectionstring;
	conn.Open();
	sp_file_row.ActiveConnection = conn;
	sp_file_row.CommandText = "sp_addData_DPP";
	sp_file_row.CommandType = adCmdStoredProc;
 
	sp_file_row.Parameters.Append(sp_file_row.CreateParameter("RETURN_VALUE", adInteger, adParamReturnValue));
	sp_file_row.Parameters.Append(sp_file_row.CreateParameter("@ProductionProfileID", adInteger, adParamInput, adDefaultSize, ProductionProfileID));
	sp_file_row.Parameters.Append(sp_file_row.CreateParameter("@Type", adInteger, adParamInput, adDefaultSize, 1250));
	sp_file_row.Parameters.Append(sp_file_row.CreateParameter("@data", adBinary, adParamInput, adMaximumSize, RowData));
	sp_file_row.Parameters.Append(sp_file_row.CreateParameter("@Create", adBoolean, adParamInput, adDefaultSize, create));
	sp_file_row.Execute();
	ret = sp_file_row.Parameters("RETURN_VALUE");
	sp_file_row.ActiveConnection.Close();
 
	return ret;
}
 
Stored procedure itself is doing just insert into table.
 
Data are binary and are given to function by 3rd party software which stores them as varbinary and when It gives them to Jscript variable it's handled as a String and every byte of binary data is converted into unicode. Then when I'm storing it into Database it's stored into varbinary column as a unicode represtentation of original bytes from binary data.
But when I run this function on czech and french system there is difference in binary data stored in my database which seems strange as unicode shoudl be same on all systems.
 
Did anyone ever encountered such a problem with encoding on different language systems and solved it?
 
Thank you Michal
Posted 30-Nov-12 4:26am

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

in the end i was able to solve this problem.
 
All was caused by ADO and its behavior when it encoded binary data from Local system language codepage to unicode.
 
in this example it was on French system from codepage 1252 to unicode and on Czech from codepage 1250 to unicode.
 
So I needed to update my program to work with binary data differently according to local system.
I did it using
CultureInfo.CurrentCulture.TextInfo.ANSICodePage; 
and then I transoformed unicode binary to origibnal binary data.
 
But I'm interested if anyone knows if it's possible to froce somehow ADO to not convert data to unicode?
  Permalink  

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 Zoltán Zörgő 320
1 CHill60 185
2 /\jmot 160
3 Peter Leow 160
4 Pikoh 125
0 Sergey Alexandrovich Kryukov 9,423
1 OriginalGriff 6,891
2 Peter Leow 4,637
3 Zoltán Zörgő 4,304
4 CHill60 2,932


Advertise | Privacy | Mobile
Web04 | 2.8.150129.1 | Last Updated 10 Dec 2012
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100