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

Please tell me how to display unicode data from sql 2005 in vb.net 2.0 windows forms combobox.

I am able to store values in database, but when it is disalying it is coming as boxes.
Posted
Comments
Member 10047627 15-May-13 5:09am    
i have password characters in my vb.net project but if i save it to my sql2005 database, its showing the normal characters.... pls how can i hide it so it will not show as normal string characters? for eg, if i use * as password character, it should show * in sql to. tankz

1 solution

You can try following code.
C#
//Code starts here
static void convertunicode()
{
string unicodeString = "This string contains the unicode character Pi(\u03a0)";

// Create two different encodings.
Encoding ascii = Encoding.ASCII;
Encoding unicode = Encoding.Unicode;

// Convert the string into a byte[].
byte[] unicodeBytes = unicode.GetBytes(unicodeString);

// Perform the conversion from one encoding to the other.
byte[] asciiBytes = Encoding.Convert(unicode, ascii, unicodeBytes);

// Convert the new byte[] into a char[] and then into a string.
// This is a slightly different approach to converting to illustrate
// the use of GetCharCount/GetChars.
char[] asciiChars = new char[ascii.GetCharCount(asciiBytes, 0, asciiBytes.Length)];
ascii.GetChars(asciiBytes, 0, asciiBytes.Length, asciiChars, 0);
string asciiString = new string(asciiChars);

// Display the strings created before and after the conversion.
Console.WriteLine("Original string: {0}", unicodeString);
Console.WriteLine("Ascii converted string: {0}", asciiString);
}
//Code Ends Here




HTH
 
Share this answer
 

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