Click here to Skip to main content
15,886,110 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,

I have a win app that contains a text box which I require to input and save text in any language - depending on the user.

I have set my db to nvarchar and if I paste directly in db it works fine. My problem is getting the textbox to accept the different languages and save the text to MS SQL using LINQ.

Any suggestions please?
Posted

1 solution

As far as I know the TextBox will accept unicode characters.

To save to SQL Server precede the text with an upper case 'N'.

TextBox.Text = Hello

Pseudo code to save to Database
SET Message = N'Hello'
 
Share this answer
 
Comments
SwitcherSoft 1-Apr-11 2:10am    
Also, make sure that the column in the table is nvarchar or nchar just to make sure that some characters are not thrown away. I agree with your solution Henry
Henry Minute 1-Apr-11 5:31am    
Thank you. The OP did say the column was NVarchar.
milenalukic 2-Apr-11 10:49am    
That works when you do it directly into SQL.
my problem is:

using(mydatacontext dc = new datacontext())
{
Table tbl = dc.tbl.first();
tbl.name = textbox.text;
dc.submitchanges();
}

If a textbox saves to a new record it works fine but here where there is an update it does not.

How can I pass the "N" into the update?
Henry Minute 2-Apr-11 10:51am    
Something like:

tbl.Name = "N'" + textbox.Text + "'";

or even:

tbl.Name = string.Format("N'{0}'", textbox.Text);
Sarit Kumar Singha 1-Dec-11 5:05am    
plz tell me how to use bengali language in textbox

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