If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > ASP > ASP and MSSQL 2005 problem with utf-8 text

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 04-14-09, 10:33
tbjornen tbjornen is offline
Registered User
 
Join Date: Jan 2009
Posts: 11
ASP and MSSQL 2005 problem with utf-8 text

Hello

I have problem inserting non-english characters into MS SQL 2005 database. My page with form that collect data is UTF-8. When I try to insert characters like čć they are stored in my MS SQL database like cc, but characters like šž are ok.

What is the problem, and how to solve it ?
Reply With Quote
  #2 (permalink)  
Old 04-14-09, 10:56
gvee gvee is offline
www.gvee.co.uk
 
Join Date: Jan 2007
Location: UK
Posts: 10,156
What data type is the target field in the database?
__________________
George
Twitter | Blog
Reply With Quote
  #3 (permalink)  
Old 04-14-09, 12:25
tbjornen tbjornen is offline
Registered User
 
Join Date: Jan 2009
Posts: 11
nvarchar, bit and int
Reply With Quote
  #4 (permalink)  
Old 04-15-09, 12:10
gvee gvee is offline
www.gvee.co.uk
 
Join Date: Jan 2007
Location: UK
Posts: 10,156
Hmm...

Can you share your insert code?
What happens if you run the stored procedure with these characters directly from Management Studio?
__________________
George
Twitter | Blog
Reply With Quote
  #5 (permalink)  
Old 04-16-09, 03:27
tbjornen tbjornen is offline
Registered User
 
Join Date: Jan 2009
Posts: 11
This is my INSERT statement:

strSQL = "INSERT INTO tbl_users (my_name, my_lastname) "VALUES ('" & strName & "', '" & strLast & "')"

I tried insert č and ć chars through Management Studio query like this:

USE
my_db

INSERT INTO tbl_users (my_name, my_lastname) VALUES ('Čićići', 'Ičićić')

But when I open table there is Cicici and Icicic. So č and ć doesnt work from management studio query either.
Reply With Quote
  #6 (permalink)  
Old 04-16-09, 07:00
gvee gvee is offline
www.gvee.co.uk
 
Join Date: Jan 2007
Location: UK
Posts: 10,156
Try this:
Code:
INSERT INTO tbl_users (my_name, my_lastname) VALUES (N'Čićići',N'Ičićić')
__________________
George
Twitter | Blog
Reply With Quote
  #7 (permalink)  
Old 04-16-09, 09:06
tbjornen tbjornen is offline
Registered User
 
Join Date: Jan 2009
Posts: 11
That works when I use it as query in Management studio, but when I use this query on my ASP page then it converts my characters into different characters. For example š = Å¡ and č = Ä
Reply With Quote
  #8 (permalink)  
Old 04-17-09, 07:32
gvee gvee is offline
www.gvee.co.uk
 
Join Date: Jan 2007
Location: UK
Posts: 10,156
Code:
...
strSQL = "INSERT INTO tbl_users (my_name, my_lastname) "VALUES ('" & strName & "', '" & strLast & "')"

Response.Write (strSQL)
Response.End
What's the print valued of strSQL exactly?
__________________
George
Twitter | Blog
Reply With Quote
  #9 (permalink)  
Old 04-27-09, 13:23
chamoore chamoore is offline
Registered User
 
Join Date: Dec 2004
Location: Istanbul
Posts: 3
collation

I think your collation is Latin1_General. Try your local collation.

I had the same problem with Turkish Chars (ı ş İ ).
I changed the collation of DB to Turkish_CI_AS. Now its ok.
Reply With Quote
  #10 (permalink)  
Old 04-27-09, 13:32
tbjornen tbjornen is offline
Registered User
 
Join Date: Jan 2009
Posts: 11
I know that I could change collation to Croatian and then Croatian characters should work but I am building an international application where it could be used croatian, french, italian or russian characters so my database must accept all kinds of characters.

I didn't solve my problem yet.
Reply With Quote
  #11 (permalink)  
Old 04-27-09, 17:40
gvee gvee is offline
www.gvee.co.uk
 
Join Date: Jan 2007
Location: UK
Posts: 10,156
Unicode (nvarchar) is collation free so changing the db collation shouldn't matter.

Can you answer my previous question (exact value of strsql) please?
__________________
George
Twitter | Blog
Reply With Quote
  #12 (permalink)  
Old 04-28-09, 01:15
chamoore chamoore is offline
Registered User
 
Join Date: Dec 2004
Location: Istanbul
Posts: 3
gvee problem is ADODB is not working properly with ASP.

I know an exact solution. But thats hard way.
You can create a Com+ DLL for executing SQL commands.

We have an international portal application which is working with VB6 Com+ DLL.
Reply With Quote
  #13 (permalink)  
Old 04-28-09, 04:35
tbjornen tbjornen is offline
Registered User
 
Join Date: Jan 2009
Posts: 11
Quote:
Originally Posted by gvee
Code:
...
strSQL = "INSERT INTO tbl_users (my_name, my_lastname) "VALUES ('" & strName & "', '" & strLast & "')"

Response.Write (strSQL)
Response.End
What's the print valued of strSQL exactly?
This is my SQL statement:

INSERT INTO tbl_users (my_name, my_lastname) VALUES ('Miroć', 'Piroć')

and when I open table in MS SQL Management there is Miroc Piroc. There is no ć character.
Reply With Quote
  #14 (permalink)  
Old 04-28-09, 04:41
gvee gvee is offline
www.gvee.co.uk
 
Join Date: Jan 2007
Location: UK
Posts: 10,156
If you add the preceding N in the ASP code, does it work?
Code:
strSQL = "INSERT INTO tbl_users (my_name, my_lastname) "VALUES (N'" & strName & "', N'" & strLast & "')"
__________________
George
Twitter | Blog
Reply With Quote
  #15 (permalink)  
Old 04-28-09, 05:12
tbjornen tbjornen is offline
Registered User
 
Join Date: Jan 2009
Posts: 11
I've found solution to my problem. When I use ADO AddNew/Update then it's all working fine.

I've tried with this code:

Code:
Set rsAdd = Server.CreateObject("ADODB.Recordset")
strSQL = "SELECT my_name, my_lastname FROM tbl_users"
rsAdd.Open strSQL, conn, 1, 3
	
rsAdd.AddNew
	
rsAdd("my_name") = strName
rsAdd("my_lastname") = strLastName
	
rsAdd.Update
Now i can insert what ever I want to my database field.
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On