Click here to Skip to main content
15,886,963 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
First of all, I would like to note that this is my last chance. I have been goggeling this problem over and over again for 5 days, and no result came up. I really hope somebody will be able to solve my problem, and I would like to thank you for reading this topic.

Well, I'm working with C# winform witch hosts an element controll of xaml type. In the user controll, I'm sending information (Hebrew text) to my Server-based Database right after I click the 'send' button. The application sens question marks instead of the needed text and thats what I see when I go into the table and check the results.

I would like to note that I have already set the field to NVarChar or nText witch SHOULD accept Unicode charactes, such as Hebrew chars. If I insert the Hebrew text into the fields by myself without using the application, it doesn't show the question marks and saves the Hebrew text as it is. The problem appears only when I try to send the data from the application.

Well I've been told that this is an encode problem, and that I should add a meta tag with sets the page language to Hebrew (UTF8 or Windows-2522), but its not possible to me since I'm not using an aspx pages in my application. All the data witch should be sent is from xaml file.
Another thought was that I should run a command like "Character Set hebrew" as an sql command, but I did not mange to get this command work for me, it just crashes the application when I use the next 2 lines:
SqlCommand cmd2 = new SqlCommand("CHARACTER SET hebrew, con);
cmd2.ExecuteNonQuery();


I have read a lot of expert suggestions with this problem, but nothing really worked for me. For example, I read somewhere that I should dynamically set the database collection to hebrew, with I just don't know how, and all the manuals I read I did not find any answer for that.


To sum up, I can't let this problem go because all my application is based on the Hebrew language and I can't just ignore it, but I really don't know what else can I do in order to make this work for me.
I really hope that one of the experts here will manage to show a working solution for this problem, and I really will be glad.

Thank you for the long reading, and sorry for wasting your time :( ,

Tom
Posted
Comments
fjdiewornncalwe 30-Dec-10 13:12pm    
What type of database server are you using?
TomNidi 30-Dec-10 15:17pm    
I guess it is an mysql database.. when I add a file using Visual Studio C# express edition I select the Server-based Database, witch is an mdf type.
Henry Minute 30-Dec-10 15:22pm    
'mdf' is normally the extension for SQLServer database files.

Now that you have established that it is the way you have coded the database related part of your application that is causing the problem, take a look at this[^] thread. In particular the second answer (third post).

This should resolve your problem.
 
Share this answer
 
Have you managed to confirm that your application is sending "?????", or maybe it sends Hebrew that gets misread somehow between your app and the database. For example, if you send to a text file instead of a database, will it read as Hebrew in a compatible text-file reader.
 
Share this answer
 
Well, I have tested the application without the database, on a regular txt file and it works fine. The text is sent normally, and when I open the txt file I see the same Hebrew text.

Well, does somebody know how to change the database codes to make sure it will accept Hebrew text?
 
Share this answer
 
Well, the code works now perfectly.
Thank you for your time and your support :)
 
Share this answer
 
Add N char befor you quated stרingת for example
insert into #tabname (f1) values (N'כן')
 
Share this answer
 
Comments
Richard Deeming 29-Aug-23 4:47am    
Aside from the fact that you're 13 years late to this question, your suggestion only applies to literal strings embedded directly within the query. If you use a properly parameterized query, then your solution adds nothing.

NB: If you're not using a parameterized query, then you're writing code which is vulnerable to SQL Injection[^].

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900