Results 1 to 7 of 7

Thread: Unicode characters showing as ?

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    May 2006
    Posts
    170

    Unicode characters showing as ?

    I have developed an application and need to allow users to enter text in any language and save it to my database. However the text is saved as '?' in my database. I have googled quite a bit and found that people have suggested not to use varchar, text types but use nvarchar and ntext etc in your database. I have gone through and made these changes to my database.

    However it still saved text as '?', I then found people where saying about adding 'N' infront of the text prior to saving into the database. The problem is that I cannot figure out how to do this in a stored procedure.

    Stored Procedure
    Code:
    CREATE PROCEDURE [dbo].[spUpdateActionTaken] @ID as varChar(4),@action as text,@modifyDate as varchar(50)
    
    AS
    
    UPDATE commentsTbl SET commActionTaken=@action,modifyDate=@modifyDate WHERE [ID]=@ID
    Note: Fields commActionTaken set to nText

    VB.Net Code
    Code:
    Dim actionTaken as String = Me.textBox.Text
    Dim myCmd As New OleDb.OleDbCommand("spUpdateActionTaken")
    myCmd.CommandType = CommandType.StoredProcedure
    myCmd.Parameters.Add(New OleDb.OleDbParameter("@ID", OleDb.OleDbType.VarChar)).Value = ID
    myCmd.Parameters.Add(New OleDb.OleDbParameter("@action", OleDb.OleDbType.VarChar)).Value = actionTaken
    myCmd.Parameters.Add(New OleDb.OleDbParameter("@modifyDate", OleDb.OleDbType.Date)).Value = Now()
    I am assuming that this is the solution or do I have to change anything else in the database? I am using MS SQL 2000 database.

    Thanks in advance

    Simon

  2. #2
    Software Carpenter dee-u's Avatar
    Join Date
    Feb 2005
    Location
    Pinas
    Posts
    11,127

    Re: Unicode characters showing as ?

    Perhaps this will help?
    Regards,


    As a gesture of gratitude please consider rating helpful posts. c",)

    Some stuffs: Mouse Hotkey | Compress file using SQL Server! | WPF - Rounded Combobox | WPF - Notify Icon and Balloon | NetVerser - a WPF chatting system

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    May 2006
    Posts
    170

    Re: Unicode characters showing as ?

    dee-u,

    Thank you for the information, however I am still unsure how to add the 'N' to the stored procedure as the example on the website uses a string value instead of arguments/variable from the stored procedure. Would my sored procedure be like this:

    Code:
    CREATE PROCEDURE [dbo].[spUpdateActionTaken] @ID as varChar(4),@action as text,@modifyDate as varchar(50)
    
    AS
    
    UPDATE commentsTbl SET commActionTaken=N@action,modifyDate=@modifyDate WHERE [ID]=@ID
    Thanks

  4. #4
    Super Moderator si_the_geek's Avatar
    Join Date
    Jul 2002
    Location
    Bristol, UK
    Posts
    41,974

    Re: Unicode characters showing as ?

    You have changed your fields from varchar/text to nvarchar/ntext, but have not changed the parameters of the procedure.

    I think it will be OK once you have done that.

  5. #5

    Thread Starter
    Addicted Member
    Join Date
    May 2006
    Posts
    170

    Re: Unicode characters showing as ?

    Thanks for the help, but unfortunately nvarchar / ntext is not supported by oledb so I am not able to make this change. Obviously I could use SQLClient but my application works with MS SQL and Oracle hence using Oledb.

    Any other suggestion?

  6. #6
    Super Moderator si_the_geek's Avatar
    Join Date
    Jul 2002
    Location
    Bristol, UK
    Posts
    41,974

    Re: Unicode characters showing as ?

    I find it very hard to believe that OLEDB doesn't support unicode, because it has been a significant thing for many years.

    What I suspect is that you are just going by the names of the data types, which do not necessarily have exactly the same meaning. Either check the help for them, or try a few things out.


    Note that as far as the parameters for the procedure go, you don't have much choice - if they aren't the N variations, you will not receive the data correctly.

  7. #7

    Thread Starter
    Addicted Member
    Join Date
    May 2006
    Posts
    170

    Re: Unicode characters showing as ?

    You are correct, I looked at the documentation for oledb and it is VarWChar for unicode string. Was looking for something like NVarChar or something.

    Thanks for your help, will try this when I get home

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width