Re: VB Chinese Code Problem

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



Unicode String constants in SQL must be prefixed by an 'N' character, e.g.

strsql = "insert into test (test) values (N'" & Text1.Text & "')"


Tony Proctor

"hon123456" <peterhon321@xxxxxxxxxxxx> wrote in message
news:1190125099.482659.112900@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
On 9 18 , 6 38 , "Tony Proctor"
<tony_proctor@xxxxxxxxxxxxxxxxxxxxxxxxxxxxx> wrote:
Column types like nvarchar will store text in Unicode format. When this
is
read into VB6 String variables it is also Unicode. Hence, you must not
apply
any further translations on top of this or it will corrupt the character
codes.

Similarly, when storing String variables back to the database, no
translation should happen because both ends are Unicode.

In order to successfully show the Chinese characters on your screen, you
must have a Chinese version of Windows. Setting the Regional setting to
English will cause those characters to appear as "??"

Can you show us some code, or provide a few more details about where the
data begins and ends?

Tony Proctor

"hon123456" <peterhon...@xxxxxxxxxxxx> wrote in message

news:1190105686.354249.254980@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx



Dear all,

I am using Chinese VB 6 in Chinese XP, and my backend is sql
server 2000. I have set
the field in Sql Server to nvarchar. I have a combo box with several
Chinese item. When I save
the record, the Chinese become ?? in the Database. I have try several
solution in following

1. Set the connection string with Auto Translate = false
2. Use Strconv function to convert the string to Unicode.
3. Download third party control Unitoolbox.
4. Set the Regional setting to English in Control Panel.

After all have been done, VB still save the Chinese into the database
with ??

What is the problem. Please help.

Thank- -

- -

Dear Tony,

I have tried not to add anything to the VB and SQL
Server, but When
the user enter Chinese Character to the Text box and save to database,
I can only
see the ?? in the SQL table Test. Please Help.

Dim Cnn As New ADODB.Connection
Dim Rst As New ADODB.Recordset
Cnn.ConnectionString = "Provider=SQLOLEDB.1;Auto
translate=false;Password=sa;Persist Security Info=True;User
ID=sa;Initial Catalog=FIH;Data Source=(local)"
Cnn.CommandTimeout = 0
Cnn.Open

Dim strsql

strsql = "insert into test (test) values ('" & Text1.Text & "')"

Cnn.Execute strsql



.



Relevant Pages

  • Re: database size
    ... > I cannot understand the database sizes as created with SQL CE 2.0. ... I'm not 100% but on full Sql Server, NVARCHAR and NText both use twice the ... with the unicode character set. ... entered)'s NText type. ...
    (microsoft.public.dotnet.framework.compactframework)
  • Re: what is the problem with this?
    ... character instead. ... I am using MSVC 2008 and Access database. ... Parameterized Methods to the Data Access Layer. ... I cannot create an sql with parameterized data. ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: How do I preserve carriage returns in SQL?
    ... We are submitting the SQL ... This is the way most of our database updates are ... applied and I've never noticed carriage returns to be an issue. ... >> character as a legal data character. ...
    (microsoft.public.data.ado)
  • Re: How to insert a string that contains or ,
    ... Now if one of the Strings contain a ' or a, character, the sql ... can i store a string that contains ' or, in the database? ...
    (comp.lang.java.databases)
  • Fixed
    ... I also found this article that gives the proper way to move system dbs in sql 2008: ... The model exists where the master states it exists. ... This is the error log prior to detaching the model database. ...
    (microsoft.public.sqlserver.server)