Click here to Skip to main content
15,914,608 members
Home / Discussions / C#
   

C#

 
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 
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 
Girish481 wrote:
First i really wish to heartly thank to you for your continue support.

You're welcome Smile | :)

Girish481 wrote:
1.How do i give/type Unicode in the textbox, something like :
Select * from mytable where name like '%ओम%' (Here i am copying from your reply)

There's a catch there, in the Sql part. If you execute that statement in Sql Server Management Studio Express (or any other Query-tool) than you'll find 0 records. The statement below should work, but..
SQL
SELECT * FROM mytable WHERE name LIKE N'%ओम%'
There's another caveat, with the .AddWithValue method on the SqlCommand class; somehow it finds 0 records again. Long story short, a bit (working) code with a workaround;
C#
public partial class Form1 : Form
{
    const String Ohm = "ओम्";
    RichTextBox myRichBox;

    public Form1()
    {
        InitializeComponent();

        myRichBox = new RichTextBox();
        myRichBox.Dock = DockStyle.Top;
        myRichBox.Text = "ओ"; // Search part of the Ohm
        this.Controls.Add(myRichBox);

        using (SqlConnection con = new SqlConnection(
            "Server=.;Database=AdventureWorks;Trusted_Connection=True;"))
        using (SqlCommand cmd = con.CreateCommand())
        {
            cmd.CommandText = 
                "UPDATE Person.Contact SET FirstName = @what WHERE ContactID = @ContactID";
            cmd.Parameters.AddWithValue("ContactID", 25);
            cmd.Parameters.AddWithValue("what", "O" + Ohm); // write full Ohm to database
            con.Open();

            cmd.ExecuteNonQuery();

            cmd.Parameters.Clear();
            cmd.CommandText = 
                "SELECT ContactID FROM Person.Contact WHERE FirstName LIKE N'%@what%'";
            // For some strange reason, adding a parameter doesn't work
            //  cmd.Parameters.AddWithValue("what", myRichBox.Text);
            // As a workaround;
            cmd.CommandText = cmd.CommandText.Replace("@what", myRichBox.Text);
            string result = cmd.ExecuteScalar().ToString();

            myRichBox.Text = "Found record @Id; " + result;
        }
    }
}
I've used the AdventureWorks database here, but it should work equally with the Northwind database. This[^] page on MSDN has some lengthy explanation.
I are Troll Suspicious | :suss:

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 
GeneralRe: Update progress bar on another form Pin
Luc Pattyn3-Mar-11 1:36
sitebuilderLuc Pattyn3-Mar-11 1:36 
GeneralRe: Update progress bar on another form Pin
DaveyM693-Mar-11 3:58
professionalDaveyM693-Mar-11 3:58 

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.