Click here to Skip to main content
15,891,607 members
Home / Discussions / C#
   

C#

 
GeneralRe: Help for code Pin
musefan2-Mar-11 23:51
musefan2-Mar-11 23:51 
AnswerRe: Help for code Pin
Eddy Vluggen2-Mar-11 23:45
professionalEddy Vluggen2-Mar-11 23:45 
GeneralRe: Help for code Pin
Girish4813-Mar-11 0:01
Girish4813-Mar-11 0:01 
GeneralRe: Help for code Pin
musefan3-Mar-11 0:06
musefan3-Mar-11 0:06 
GeneralRe: Help for code Pin
Girish4813-Mar-11 0:47
Girish4813-Mar-11 0:47 
GeneralRe: Help for code Pin
Eddy Vluggen3-Mar-11 1:06
professionalEddy Vluggen3-Mar-11 1:06 
GeneralRe: Help for code Pin
Girish4813-Mar-11 3:38
Girish4813-Mar-11 3:38 
GeneralRe: Help for code Pin
Eddy Vluggen3-Mar-11 6:45
professionalEddy Vluggen3-Mar-11 6:45 
Girish481 wrote:
Probably i am not able to explain my need

No worries; text-encoding is a though subject and I'm not very good at explaining either.

Girish481 wrote:
. See, whatever you have said, that is fine that if i says dim x as string="Hindi Words"; they are visible in the dotnet;

Strings in .NET are in Unicode, in UTF8 to be precise. (UTF7, 8, 16 and 32 are all Unicode-formats), but Windows was around long before .NET - not everything is prepared for multibyte-characters. As a test, you can create a new project in Visual Studio and replace the code from Form1 with this code;
C#
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Data.SqlClient;

public partial class Form1 : Form
{
    const String ओम् = "ॐ (that's Ohm)"; // Hindi character (both in var-name and contents!)
    TextBox myTextBox;
    RichTextBox myRichBox;

    public Form1()
    {
        InitializeComponent();

        myTextBox = new TextBox();
        myTextBox.Dock = DockStyle.Top;
        myTextBox.Text = ओम्;
        this.Controls.Add(myTextBox);

        myRichBox = new RichTextBox();
        myRichBox.Dock = DockStyle.Top;
        myRichBox.Text = ओम्;
        this.Controls.Add(myRichBox);

        String cs = "Server=.;Database=Northwind;Trusted_Connection=True;";
        using (SqlConnection con = new SqlConnection(cs))
        using (SqlCommand cmd = con.CreateCommand())
        {
            // prep command
            cmd.CommandText = "UPDATE Customers SET CompanyName = @what WHERE ContactName = @ContactName";
            cmd.Parameters.AddWithValue("ContactName", "Antonio Moreno");
            cmd.Parameters.AddWithValue("what", ओम्);
            con.Open();
            
            // update that contact to have the Ohm-string in it's companyname
            // this is to prove that the character is stored in Sql Server.
            // We'll be searching for this character in the next query;
            cmd.ExecuteNonQuery();

            // now find that contact by using the Ohm-character and the Sql like operator            
            cmd.Parameters.Clear();
            cmd.CommandText = "SELECT CompanyName + '.' + ContactName FROM Customers WHERE CompanyName LIKE @bla";
            cmd.Parameters.AddWithValue("bla", "%ॐ%"); // search for any records containing the Ohm-character in column CompanyName
            string result = cmd.ExecuteScalar().ToString();

            myTextBox.Text = result; // should display a box-character with a name (this is what you wanted to prevent)
            myRichBox.Text = result; // should display a Ohm-character with a name (this is per your requirement)
        }
    }
}
Visual Studio should complain that you're using non-standard characters and it should propose to save it in a "universal" format - that's going to be Unicode again. If you have the Nortwind-database installed than you can execute this code as is, otherwise you'll have to change the table-names.

If all is well, it'd update a record in that database and search that record again - displaying the result in both textboxes.
Girish481 wrote:
1.How do i convert Unicode Text to Edibable Text?

As the example shows, Unicode is editable. Not every control understands unicode, which might be the reason why your seeing blocks (or question marks) in certain controls. It should also be noted that most databases expect ASCII/ANSI for text-fields, having special fields for multibyte-character sets. In Sql Server, that'd be the datatypes that are prefixed with an 'N', like NVARCHAR.

Girish481 wrote:
and the SQL Server Error is :

Are you concatenating the parameter to the command (like "SELECT " + textbox1.Text) or are you using a SqlParameter to fill in the parameters of the query?

Hope this gets you going in the right direction Smile | :)
I are Troll Suspicious | :suss:

GeneralRe: Help for code Pin
Girish4813-Mar-11 23:48
Girish4813-Mar-11 23:48 
GeneralRe: Help for code Pin
Eddy Vluggen4-Mar-11 12:16
professionalEddy Vluggen4-Mar-11 12:16 
GeneralRe: Help for code Pin
Girish4815-Mar-11 16:56
Girish4815-Mar-11 16:56 
GeneralRe: Help for code Pin
Eddy Vluggen6-Mar-11 0:42
professionalEddy Vluggen6-Mar-11 0:42 
QuestionHow do you protect your app hosting third party dll ...? [modified] Pin
devvvy2-Mar-11 21:32
devvvy2-Mar-11 21:32 
AnswerRe: How do you protect your app hosting third party dll ...? Pin
Eddy Vluggen3-Mar-11 6:58
professionalEddy Vluggen3-Mar-11 6:58 
GeneralRe: How do you protect your app hosting third party dll ...? Pin
devvvy3-Mar-11 15:21
devvvy3-Mar-11 15:21 
GeneralRe: How do you protect your app hosting third party dll ...? Pin
Eddy Vluggen4-Mar-11 11:04
professionalEddy Vluggen4-Mar-11 11:04 
GeneralRe: How do you protect your app hosting third party dll ...? [modified] Pin
devvvy4-Mar-11 22:28
devvvy4-Mar-11 22:28 
GeneralRe: How do you protect your app hosting third party dll ...? Pin
Eddy Vluggen5-Mar-11 3:02
professionalEddy Vluggen5-Mar-11 3:02 
GeneralRe: How do you protect your app hosting third party dll ...? Pin
devvvy5-Mar-11 14:24
devvvy5-Mar-11 14:24 
GeneralRe: How do you protect your app hosting third party dll ...? Pin
Eddy Vluggen7-Mar-11 0:41
professionalEddy Vluggen7-Mar-11 0:41 
GeneralRe: How do you protect your app hosting third party dll ...? Pin
devvvy7-Mar-11 14:27
devvvy7-Mar-11 14:27 
QuestionUpdate progress bar on another form Pin
Etienne_1232-Mar-11 21:28
Etienne_1232-Mar-11 21:28 
AnswerRe: Update progress bar on another form Pin
musefan2-Mar-11 22:29
musefan2-Mar-11 22:29 
GeneralRe: Update progress bar on another form Pin
Etienne_1233-Mar-11 21:17
Etienne_1233-Mar-11 21:17 
AnswerRe: Update progress bar on another form Pin
DaveyM693-Mar-11 1:13
professionalDaveyM693-Mar-11 1:13 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.