.NET 4.0 DynamicData: How to save fields as unicode or UTF-8 to MS SQL 2005? RRS feed

  • Question

  • User-427383459 posted

    Hi all, 

    I've done .NET 4.0 DynamicData website with VisualStudio, my database is on a MS SQL 2005 server and I connect to . 

    All is fine and dandy, thanks to this forum and Asp.net's Getting Started videos, except I cannot figure out how to save to database a textfield which contains other than Windows-1252 characters, Russian characters for example (Windows-1251). 

    In the olden days, with classic asp, I've done something like this:

    Set objConnection = Server.CreateObject("ADODB.Connection")
    objConnection.Open "DSN=mydataset;UID=mylogin;PWD=mypw"
    strSqlStmt = "INSERT INTO mytable values ("
    strSqlStmt = strSqlStmt & "'myfirstvalue', "
    strSqlStmt = strSqlStmt & "N''Some Russian: ёЁйЙцЦ')"
    '                          ^
    'N means that the <--------+
    'characters are saved in Unicode format. 
    Set objRs = objConnection.Execute(strSqlStmt)

    How do I do the "N'" -thing with .NET 4.0 DynamicData?

    Tuesday, August 7, 2012 6:04 AM


  • User-427383459 posted

    Hi again, 

    I'm answering my own question:

    You need to define the database column correctly. My field's (or column as its is called in MS SQL) datatype was varchar as it should have been nvarchar

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, August 7, 2012 9:54 AM