| |
|
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.
|
 |

04-14-09, 10:33
|
|
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 ?
|
|

04-14-09, 10:56
|
|
www.gvee.co.uk
|
|
Join Date: Jan 2007
Location: UK
Posts: 10,156
|
|
What data type is the target field in the database?
|
|

04-14-09, 12:25
|
|
Registered User
|
|
Join Date: Jan 2009
Posts: 11
|
|
|
|

04-15-09, 12:10
|
|
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?
|
|

04-16-09, 03:27
|
|
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.
|
|

04-16-09, 07:00
|
|
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ć')
|
|

04-16-09, 09:06
|
|
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 č = Ä
|
|

04-17-09, 07:32
|
|
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?
|
|

04-27-09, 13:23
|
|
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.
|
|

04-27-09, 13:32
|
|
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.
|
|

04-27-09, 17:40
|
|
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?
|
|

04-28-09, 01:15
|
|
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.
|
|

04-28-09, 04:35
|
|
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.
|
|

04-28-09, 04:41
|
|
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 & "')"
|
|

04-28-09, 05:12
|
|
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.
|
|
| Thread Tools |
Search this Thread |
|
|
|
| Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
|