Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Help for code

Help for code

Scheduled Pinned Locked Moved C#
regexvisual-studiocomhelp
18 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • G Girish481

    I am using below code from below link:

    using System.Globalization;
    using System.Text.RegularExpressions;
    string strValue= "0932;093E;0926;0947;0928;";
    Regex rgexp = new Regex(@"([0-9A-Fa-f]{4});");
    string strResult= rgexp .Replace(strValue, match => ((char)Int32.Parse(match.Groups[1].Value, NumberStyles.HexNumber)).ToString());
    Response.Write(strResult);

    Source:http://www.dotnetspider.com/resources/39073-How-convert-hindi-using-unicode.aspx But there is red line with match = "> (Here it is showing red line)" I am going to convert a Unicode String to Hindi (Indian Language). I am using VS 2005 Prof Edition. Thanks.

    P Offline
    P Offline
    Pravin Patil Mumbai
    wrote on last edited by
    #3

    and what is the error message that it shows..?

    G 1 Reply Last reply
    0
    • G Girish481

      I am using below code from below link:

      using System.Globalization;
      using System.Text.RegularExpressions;
      string strValue= "0932;093E;0926;0947;0928;";
      Regex rgexp = new Regex(@"([0-9A-Fa-f]{4});");
      string strResult= rgexp .Replace(strValue, match => ((char)Int32.Parse(match.Groups[1].Value, NumberStyles.HexNumber)).ToString());
      Response.Write(strResult);

      Source:http://www.dotnetspider.com/resources/39073-How-convert-hindi-using-unicode.aspx But there is red line with match = "> (Here it is showing red line)" I am going to convert a Unicode String to Hindi (Indian Language). I am using VS 2005 Prof Edition. Thanks.

      M Offline
      M Offline
      musefan
      wrote on last edited by
      #4

      If I copy that code, then it works fine for me. If you are getting an error around the => part (known as lambda expression[^]) then perhaps you are not using the correct version of .Net required to do this which is .Net 3.5 or above (I think) EDIT Change target framework[^] (VS 2008 but I am sure you will work it out for 2005) ...if version 3.5 or higher is not available then you will most likely need to install it first CORRECTION ...actually you will need to get a copy of VS 2008 or VS 2010 if you want to use .Net 3.5 or higher

      Don't vote my posts down just because you don't understand them - if you lack the superior intelligence that I possess then simply walk away

      modified on Thursday, March 3, 2011 5:53 AM

      L 1 Reply Last reply
      0
      • P Pravin Patil Mumbai

        and what is the error message that it shows..?

        G Offline
        G Offline
        Girish481
        wrote on last edited by
        #5

        Thanks for your reply. Here it is the code: private void button1_Click(object sender, EventArgs e) { string strValue= "0932;093E;0926;0947;0928;"; Regex rgexp = new Regex(@"([0-9A-Fa-f]{4});"); string strResult= rgexp.Replace(strValue, match => ((char)Int32.Parse(match.Groups[1].Value, NumberStyles.HexNumber)).ToString()); textBox1.Text=strResult; } And the error : Invalid expression term '>' Even i am not able to resolve the issue from link given by first user please. Thank you.

        1 Reply Last reply
        0
        • G Girish481

          I am using below code from below link:

          using System.Globalization;
          using System.Text.RegularExpressions;
          string strValue= "0932;093E;0926;0947;0928;";
          Regex rgexp = new Regex(@"([0-9A-Fa-f]{4});");
          string strResult= rgexp .Replace(strValue, match => ((char)Int32.Parse(match.Groups[1].Value, NumberStyles.HexNumber)).ToString());
          Response.Write(strResult);

          Source:http://www.dotnetspider.com/resources/39073-How-convert-hindi-using-unicode.aspx But there is red line with match = "> (Here it is showing red line)" I am going to convert a Unicode String to Hindi (Indian Language). I am using VS 2005 Prof Edition. Thanks.

          L Offline
          L Offline
          Lost User
          wrote on last edited by
          #6

          Girish481 wrote:

          Unicode String to Hindi

          Could you explain that? AFAIK, Unicode supports all characters. You're going to save it as ANSI with a Hindi-codepage? What are you trying to achieve?

          Girish481 wrote:

          I am using VS 2005 Prof Edition.

          Would be .NET 2.0, and that doesn't support Lambda-statements. You'll have to convert it to a real method, or upgrade to a newer version of .NET.

          I are Troll :suss:

          G 2 Replies Last reply
          0
          • M musefan

            If I copy that code, then it works fine for me. If you are getting an error around the => part (known as lambda expression[^]) then perhaps you are not using the correct version of .Net required to do this which is .Net 3.5 or above (I think) EDIT Change target framework[^] (VS 2008 but I am sure you will work it out for 2005) ...if version 3.5 or higher is not available then you will most likely need to install it first CORRECTION ...actually you will need to get a copy of VS 2008 or VS 2010 if you want to use .Net 3.5 or higher

            Don't vote my posts down just because you don't understand them - if you lack the superior intelligence that I possess then simply walk away

            modified on Thursday, March 3, 2011 5:53 AM

            L Offline
            L Offline
            Lost User
            wrote on last edited by
            #7

            VS2005 only supports the 2.0 framework. He'd have to compile by hand if he's going to use 3.0, or download VS2k8 Express :)

            I are Troll :suss:

            M 1 Reply Last reply
            0
            • L Lost User

              VS2005 only supports the 2.0 framework. He'd have to compile by hand if he's going to use 3.0, or download VS2k8 Express :)

              I are Troll :suss:

              M Offline
              M Offline
              musefan
              wrote on last edited by
              #8

              :sigh: ...you may have your knowledge, but at least I have my youth! ;P I see[^], exactly for the same reason why the OP is having the problem

              Don't vote my posts down just because you don't understand them - if you lack the superior intelligence that I possess then simply walk away

              1 Reply Last reply
              0
              • L Lost User

                Girish481 wrote:

                Unicode String to Hindi

                Could you explain that? AFAIK, Unicode supports all characters. You're going to save it as ANSI with a Hindi-codepage? What are you trying to achieve?

                Girish481 wrote:

                I am using VS 2005 Prof Edition.

                Would be .NET 2.0, and that doesn't support Lambda-statements. You'll have to convert it to a real method, or upgrade to a newer version of .NET.

                I are Troll :suss:

                G Offline
                G Offline
                Girish481
                wrote on last edited by
                #9

                If it is due to older framework version; then i will test the code on another machine and will post the output/error (if any). Thank you very much for your replies.

                M 1 Reply Last reply
                0
                • G Girish481

                  If it is due to older framework version; then i will test the code on another machine and will post the output/error (if any). Thank you very much for your replies.

                  M Offline
                  M Offline
                  musefan
                  wrote on last edited by
                  #10

                  As Eddy has said, you need to use a newer version of VS (i.e. 2008 or 2010) in order for the compiler to accept the lambda expressions. It is not just the installed version that is required

                  Don't vote my posts down just because you don't understand them - if you lack the superior intelligence that I possess then simply walk away

                  1 Reply Last reply
                  0
                  • L Lost User

                    Girish481 wrote:

                    Unicode String to Hindi

                    Could you explain that? AFAIK, Unicode supports all characters. You're going to save it as ANSI with a Hindi-codepage? What are you trying to achieve?

                    Girish481 wrote:

                    I am using VS 2005 Prof Edition.

                    Would be .NET 2.0, and that doesn't support Lambda-statements. You'll have to convert it to a real method, or upgrade to a newer version of .NET.

                    I are Troll :suss:

                    G Offline
                    G Offline
                    Girish481
                    wrote on last edited by
                    #11

                    >What are you trying to achieve? Actually i have got couple of files named like file1.txt, file2.txt etc... and these files are having unicode data too. I have to store these files data into databases like Oracle, SQL Server. So, i was in search to first convert a unicode string to convert it into editable text; i.e. something like : Unicode String is "This is a unicode string" and i wish : New String is : "Something text after conversion"; and then if i select hindi (an Indian Language) font for new string; it will show me the original string as it was in Unicode. Now, here i do'nt know how do i know the complete steps to convert these files into that format; so that i can store those data into databases. Thank you.

                    L 1 Reply Last reply
                    0
                    • G Girish481

                      >What are you trying to achieve? Actually i have got couple of files named like file1.txt, file2.txt etc... and these files are having unicode data too. I have to store these files data into databases like Oracle, SQL Server. So, i was in search to first convert a unicode string to convert it into editable text; i.e. something like : Unicode String is "This is a unicode string" and i wish : New String is : "Something text after conversion"; and then if i select hindi (an Indian Language) font for new string; it will show me the original string as it was in Unicode. Now, here i do'nt know how do i know the complete steps to convert these files into that format; so that i can store those data into databases. Thank you.

                      L Offline
                      L Offline
                      Lost User
                      wrote on last edited by
                      #12

                      Girish481 wrote:

                      I have to store these files data into databases like Oracle, SQL Server. So, i was in search to first convert a unicode string to convert it into editable text; i.e. something like :

                      Every string in .NET is in Unicode, it's the default nowadays. Meaning that you only need to read the text and pass it on to your database. Do make sure that your database also stores them in that format.

                      Girish481 wrote:

                      Unicode String is "This is a unicode string" and i wish :
                      New String is : "Something text after conversion";

                      That doesn't make sense. Unicode contains Hindi-characters - what would you want to convert them into?

                      Girish481 wrote:

                      and then if i select hindi (an Indian Language) font for new string; it will show me the original string as it was in Unicode.

                      Both show the original string in the same encoding, only with different fonts. Some fonts are designed for use with ANSI and a specfic codepage, others were created for unicode[^]. Your string in Hindi should look allright when displayed as unicode in one of those fonts.

                      I are Troll :suss:

                      G 1 Reply Last reply
                      0
                      • L Lost User

                        Girish481 wrote:

                        I have to store these files data into databases like Oracle, SQL Server. So, i was in search to first convert a unicode string to convert it into editable text; i.e. something like :

                        Every string in .NET is in Unicode, it's the default nowadays. Meaning that you only need to read the text and pass it on to your database. Do make sure that your database also stores them in that format.

                        Girish481 wrote:

                        Unicode String is "This is a unicode string" and i wish :
                        New String is : "Something text after conversion";

                        That doesn't make sense. Unicode contains Hindi-characters - what would you want to convert them into?

                        Girish481 wrote:

                        and then if i select hindi (an Indian Language) font for new string; it will show me the original string as it was in Unicode.

                        Both show the original string in the same encoding, only with different fonts. Some fonts are designed for use with ANSI and a specfic codepage, others were created for unicode[^]. Your string in Hindi should look allright when displayed as unicode in one of those fonts.

                        I are Troll :suss:

                        G Offline
                        G Offline
                        Girish481
                        wrote on last edited by
                        #13

                        I am sorry for being late reply. Probably i am not able to explain my need. See, whatever you have said, that is fine that if i says dim x as string="Hindi Words"; they are visible in the dotnet; but i want to convert them into "editable text", wish to apply some sort of font displays like bold, italic, color change etc. so, that i can say select * from mytable where name like '%Some Search String based upon Hindi words..%'. Here issue is that they are visible in IDE and Textboxes; but how do i give select criteria in the textbox so that database can see the query as mentioned above please. Please let me know : 1.How do i convert Unicode Text to Edibable Text? 2.It would be more helpful if you please show me some code in action. @ the moment; i am reading below link... but Ouch...it is also returning error.... Please scorll down and read the reply posted by Atul Bari... http://nishantpant.wordpress.com/2007/01/04/how-to-convertdisplay-a-unicode-string-in-vbnet/ and the SQL Server Error is : Msg 102, Level 15, State 1, Procedure Hex, Line 11 Incorrect syntax near '‘'. Msg 102, Level 15, State 1, Procedure Hex, Line 20 Incorrect syntax near '‘'. Msg 102, Level 15, State 1, Procedure Hex, Line 29 Incorrect syntax near '‘'. Msg 102, Level 15, State 1, Procedure Hex, Line 38 Incorrect syntax near '‘'. Msg 102, Level 15, State 1, Procedure Hex, Line 52 Incorrect syntax near 'end'. Thank you very much for your continue support.

                        L 1 Reply Last reply
                        0
                        • G Girish481

                          I am sorry for being late reply. Probably i am not able to explain my need. See, whatever you have said, that is fine that if i says dim x as string="Hindi Words"; they are visible in the dotnet; but i want to convert them into "editable text", wish to apply some sort of font displays like bold, italic, color change etc. so, that i can say select * from mytable where name like '%Some Search String based upon Hindi words..%'. Here issue is that they are visible in IDE and Textboxes; but how do i give select criteria in the textbox so that database can see the query as mentioned above please. Please let me know : 1.How do i convert Unicode Text to Edibable Text? 2.It would be more helpful if you please show me some code in action. @ the moment; i am reading below link... but Ouch...it is also returning error.... Please scorll down and read the reply posted by Atul Bari... http://nishantpant.wordpress.com/2007/01/04/how-to-convertdisplay-a-unicode-string-in-vbnet/ and the SQL Server Error is : Msg 102, Level 15, State 1, Procedure Hex, Line 11 Incorrect syntax near '‘'. Msg 102, Level 15, State 1, Procedure Hex, Line 20 Incorrect syntax near '‘'. Msg 102, Level 15, State 1, Procedure Hex, Line 29 Incorrect syntax near '‘'. Msg 102, Level 15, State 1, Procedure Hex, Line 38 Incorrect syntax near '‘'. Msg 102, Level 15, State 1, Procedure Hex, Line 52 Incorrect syntax near 'end'. Thank you very much for your continue support.

                          L Offline
                          L Offline
                          Lost User
                          wrote on last edited by
                          #14

                          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;

                          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.AddWith
                          
                          G 1 Reply Last reply
                          0
                          • L Lost User

                            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;

                            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.AddWith
                            
                            G Offline
                            G Offline
                            Girish481
                            wrote on last edited by
                            #15

                            First i really wish to heartly thank to you for your continue support. Thats a really very good, clear and helpful reply for me; but still issues are there: 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) I think if any how i am able to convert this ओम into "vkse" then it is how i wish to store the data in the table. Here "vkse" is the hindi translation of ओम if i select any Hindi font please; or if you still feel that i am not explaning my need properly; please contact at my mail id i.e. gksharmaajmer@gmail.com Thank you.

                            L 1 Reply Last reply
                            0
                            • G Girish481

                              First i really wish to heartly thank to you for your continue support. Thats a really very good, clear and helpful reply for me; but still issues are there: 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) I think if any how i am able to convert this ओम into "vkse" then it is how i wish to store the data in the table. Here "vkse" is the hindi translation of ओम if i select any Hindi font please; or if you still feel that i am not explaning my need properly; please contact at my mail id i.e. gksharmaajmer@gmail.com Thank you.

                              L Offline
                              L Offline
                              Lost User
                              wrote on last edited by
                              #16

                              Girish481 wrote:

                              First i really wish to heartly thank to you for your continue support.

                              You're welcome :)

                              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..

                              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;

                              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[

                              G 1 Reply Last reply
                              0
                              • L Lost User

                                Girish481 wrote:

                                First i really wish to heartly thank to you for your continue support.

                                You're welcome :)

                                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..

                                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;

                                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[

                                G Offline
                                G Offline
                                Girish481
                                wrote on last edited by
                                #17

                                Even though i have not yet tried your code in my machine (VS 2010) because you are showing the code in a different approach, but my need/question is different. I agree that if i runs your code it will work fine if table is having Unicode Strings in the columns; but my question is "How i will give Unicode Strings in the Textbox to search the table" like : select * from mytable where col1=Textbox1.Text (Here how do i supply Unicode in the Textbox). Whereas, if i were able to store converted strings in the column then i think it is more flexible to handle the data, because now it is converted and editable to any tool. Something like if table is having Unicode values then problem is how do i supply / search in the table using textbox1 and then populate my FlexGrid. I think its going a larger thread on the forum, thats why i gave you my mail id; so that if i gets the final and the complete answer; then i will post your code here; so that other user of the forum may get handy answer as well. Best Regards.

                                L 1 Reply Last reply
                                0
                                • G Girish481

                                  Even though i have not yet tried your code in my machine (VS 2010) because you are showing the code in a different approach, but my need/question is different. I agree that if i runs your code it will work fine if table is having Unicode Strings in the columns; but my question is "How i will give Unicode Strings in the Textbox to search the table" like : select * from mytable where col1=Textbox1.Text (Here how do i supply Unicode in the Textbox). Whereas, if i were able to store converted strings in the column then i think it is more flexible to handle the data, because now it is converted and editable to any tool. Something like if table is having Unicode values then problem is how do i supply / search in the table using textbox1 and then populate my FlexGrid. I think its going a larger thread on the forum, thats why i gave you my mail id; so that if i gets the final and the complete answer; then i will post your code here; so that other user of the forum may get handy answer as well. Best Regards.

                                  L Offline
                                  L Offline
                                  Lost User
                                  wrote on last edited by
                                  #18

                                  Girish481 wrote:

                                  Something like if table is having Unicode values then problem is how do i supply / search in the table using textbox1 and then populate my FlexGrid.

                                  Searching is done using the LIKE operator as shown. Giving the user an easy way to enter values would be harder; some languages would require their own IME-editor[^]. If the keyboard can't supply all characters, then you'll need one of those.

                                  I are Troll :suss:

                                  1 Reply Last reply
                                  0
                                  Reply
                                  • Reply as topic
                                  Log in to reply
                                  • Oldest to Newest
                                  • Newest to Oldest
                                  • Most Votes


                                  • Login

                                  • Don't have an account? Register

                                  • Login or register to search.
                                  • First post
                                    Last post
                                  0
                                  • Categories
                                  • Recent
                                  • Tags
                                  • Popular
                                  • World
                                  • Users
                                  • Groups