Click here to Skip to main content
13,090,730 members (45,679 online)
Rate this:
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;
	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));
	ret = sp_file_row.Parameters("RETURN_VALUE");
	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 3:26am

1 solution

Rate this: bad
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

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?

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

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy |
Web04 | 2.8.170813.1 | Last Updated 10 Dec 2012
Copyright © CodeProject, 1999-2017
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