Results 1 to 15 of 15
  1. #1
    Join Date
    Jan 2009
    Posts
    11

    Unanswered: 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 ?

  2. #2
    Join Date
    Jan 2007
    Location
    UK
    Posts
    11,434
    Provided Answers: 10
    What data type is the target field in the database?
    George
    Home | Blog

  3. #3
    Join Date
    Jan 2009
    Posts
    11
    nvarchar, bit and int

  4. #4
    Join Date
    Jan 2007
    Location
    UK
    Posts
    11,434
    Provided Answers: 10
    Hmm...

    Can you share your insert code?
    What happens if you run the stored procedure with these characters directly from Management Studio?
    George
    Home | Blog

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

  6. #6
    Join Date
    Jan 2007
    Location
    UK
    Posts
    11,434
    Provided Answers: 10
    Try this:
    Code:
    INSERT INTO tbl_users (my_name, my_lastname) VALUES (N'Čićići',N'Ičićić')
    George
    Home | Blog

  7. #7
    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 č = Ä

  8. #8
    Join Date
    Jan 2007
    Location
    UK
    Posts
    11,434
    Provided Answers: 10
    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
    Home | Blog

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

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

  11. #11
    Join Date
    Jan 2007
    Location
    UK
    Posts
    11,434
    Provided Answers: 10
    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
    Home | Blog

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

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

  14. #14
    Join Date
    Jan 2007
    Location
    UK
    Posts
    11,434
    Provided Answers: 10
    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
    Home | Blog

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

Posting Permissions

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