none
How can i insert urdu in database using c# RRS feed

  • Question

  • Dear concerned,

     

    How can i insert urdu in database using c#, I found text in database like (?????????????) when insert urdu into database, please help me

    Saturday, April 19, 2008 5:54 AM

Answers

  • Hi, MuhammadArfan

     

    First please make sure your SQL Server Management Studio (SSMS) has no problems displaying Urdu language. You may check this out by inserting a record that contains Urdu manually in SSMS. You may retrieve a record which contains “???” and try to display it in your application.

     

    The next cause might be that there is something wrong with the way you insert the record. You can use the SQL Server Profiler tool to inspect the SQL statement (or if you use stored procedure, you can see the arguments passed to it):

    http://msdn2.microsoft.com/en-us/library/ms173757.aspx

     

    If you still couldn’t find the cause, please tell us what you’ve done and post some code you used to insert records.

     

     

    Best Regards

    Chunsheng Tang

     

    Tuesday, April 22, 2008 8:56 AM

All replies

  • And how are you inserting the data... I would recommend the use of parameters...

    Code Snippet

    using(SqlConnection conn = new SqlConnection(xxxx))
    {
     conn.Open();

     using(SqlCommand cmd = conn.CreateCommand())
     {
      cmd.CommandText = "INSERT INTO mytable ( mycolumn ) VALUES ( @myname )";
      cmd.Parameters.Add("@myname", SqlDbType.NVarchar).Value = "urdu";
      cmd.ExecuteNonQuery();
     }
    }



    (If that still doesn't work you'll have to look into the collaction type of your db )
    Saturday, April 19, 2008 8:02 AM
  •  MuhammadArfan wrote:

    Dear concerned,

     

    How can i insert urdu in database using c#, I found text in database like (?????????????) when insert urdu into database, please help me

     

    Can you at least try litle more to describe the problem better. When you got string with question marks '????????' that is a sign that you sent a command that had a string which is converted in default database collation from where the command is issued. If that conversion is imposible then you will have that result. There are two solutions, one is to have valid collation, and second is to put N character in front of the string: N'mystring' . Here are some details about that:
    http://msdn2.microsoft.com/en-us/library/ms179886.aspx

    Saturday, April 19, 2008 8:43 AM
  • Assuming that you are using unicode for storing  urdu language characters in the database, you need to use a unicode enabled database client to be able to view the characters.  For oracle, here are some unicode clients : http://wiki.oracle.com/page/Unicode+Enabled+Clients?t=anon

    Saturday, April 19, 2008 8:59 AM
  •  

    When i insert urdu into database using c# into sqlserver2005, it comes in database in the form of ???????????????????????? and when i select this data from database, i got ??????????????. Not original word, that i was stored into database.
    Saturday, April 19, 2008 10:32 AM
  • Hi, MuhammadArfan

     

    First please make sure your SQL Server Management Studio (SSMS) has no problems displaying Urdu language. You may check this out by inserting a record that contains Urdu manually in SSMS. You may retrieve a record which contains “???” and try to display it in your application.

     

    The next cause might be that there is something wrong with the way you insert the record. You can use the SQL Server Profiler tool to inspect the SQL statement (or if you use stored procedure, you can see the arguments passed to it):

    http://msdn2.microsoft.com/en-us/library/ms173757.aspx

     

    If you still couldn’t find the cause, please tell us what you’ve done and post some code you used to insert records.

     

     

    Best Regards

    Chunsheng Tang

     

    Tuesday, April 22, 2008 8:56 AM
  • Irfan,

    Perform the following checks and you will be able to see the Urdu text in your database:

    • Check if the target field is of nvarchar type. Urdu can be saved into the database as unicode only.
    • Try saving some Urdu text into the table in SQL Server Management Studio directly (i.e. not from C#), as told by Tang.
    • Check your regional settings in Windows to see if Urdu is added to windows languages, this will enable you to see urdu text in C#. If Urdu is not added, add it. (you might require Windows's CD to install this extra language, so make sure you have it near).
    • Make a SQLParameter and then pass it on to your SQLCommand object, and specify the DB type of this SQL Parameter to be of nvarchar type.
    Let me know if it helps, and if not then you can ping me. I made a similar application where I saved Urdu text from C# to SQL Server.

    Cheers,
    Azar Ali Zain.

    Thursday, June 19, 2008 12:04 AM
  • can you poste some code for help. Also if i saved urdu as /uAE34 in database and when through query i want to retrieve that data i m unable to get urdu character.

     

    can you help. urgent

     

    thnx

    Wednesday, August 18, 2010 5:05 AM
  • Dear Just use N of any unicode String for example    N'اسلم'    and insert into sql server database
    Wednesday, September 15, 2010 7:16 PM
  • but if u write "urdu text" in Query then error will become of datatype...
    Monday, May 23, 2011 3:09 PM
  • How can i write urdu from keyboard... plzzzzzzzzzzzzzzzz tell me
    Monday, May 23, 2011 3:10 PM
  • Let me try to help.

    I am working on a similar issue but in my case I was just researching it from a LINQ C# insertion perspective and saw you were having trouble.

    In case anybody else ends up here having ????? (question marks) appear after setting your datatype to support unicode, i.e. nvarchar (BUT NOT NTEXT as it is being deprecated (SO GLAD I FOUND THAT OUT BEFORE GOING LIVE AND BEING SCREWED!) here is the deal!

    You have to wrap the text you wish to insert into sql in 

    N'<ACTUAL TEXT GOES HERE>'

    I did not see that mentioned here.

    Further you may need to change the FONT in your sql management studio to one that supports unicode under Tools->Options.

    I have to say whenever I end up on a MSFT official help page it like there are no real programmers manning the helm, but rather just a bunch of link jockeys.

    Here is some test sql I used in management studio to get it working. Note the N'<text>' syntax and you should be on to the next issue.

    update tasks set description = N'Aristotle Krafto say, ''ανεβάσετε τα χαρακτηριστικά του παρόντος! Βράχος επάνω!! Χρησιμοποιείτ''' where task='Dr. Krafto Polyglot'

     

     

     

     

    Monday, July 4, 2011 9:13 AM
  • Hi follow this link for save urdu in database using c sharp source code also attach for download.. http://codingresolved.com/discu ssion/218/how-to-save-urdu-in-sql-server-using-c#Item_1
    • Edited by Waqas Silat Sunday, January 20, 2013 7:11 PM
    • Proposed as answer by Waqas Silat Sunday, January 20, 2013 7:11 PM
    Sunday, January 20, 2013 7:10 PM
  • You can download Pak Urdu Installer.
    Then all you need is to press Shift+Alt key to toggle Language between English and Urdu.
    Note: I used above method in Windows Operating System. Don't know about other Operating Systems.
    Tuesday, September 3, 2019 1:36 PM