Unicode characters showing as ?

lidds

Well-known member
Joined
Oct 19, 2004
Messages
122
Programming Experience
Beginner
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
VB.NET:
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
VB.NET:
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
 
Fields commActionTaken set to nText
But your SP has action parameter declared as type text which is non-unicode, also your OleDbParameter is set to OleDbType.VarChar which is non-unicode as opposed to OleDbType.VarWChar.

When using Sql Server you should probably use Sql provider rather than OleDB.
 
Back
Top