How to insert cyrillic characters into my database?
I have a table Articlesand web API controller with CRUD operations.
Articles { id: int, summary: nvarchar, text: ntext }
If I insert data using t-sql like
insert into Articles values (1, N'', N' ')
everything works fine - the data in the database is fine - all Russian characters look good.
But if I insert data using the ajax 'text' field, filled with question marks: '??????????????? ''
$.post("http://localhost:1000/api/articles",
{
id: 1,
summary: "",
text: " "
}
).always(function(res) {console.log(res)} );
Where is my mistake?
PS: connectionString, if necessary:
<add name="DefaultConnection" connectionString="Data Source=xxx;Initial Catalog=yyy;User ID=zzz;Password=***;" providerName="System.Data.SqlClient"/>
PPS: I use the automatic POST deafult action from WebAPI:
[ResponseType(typeof(Article))]
public IHttpActionResult PostArticle(Article article)
{
if (!ModelState.IsValid)
{
return BadRequest(ModelState);
}
db.Articles.Add(article);
db.SaveChanges();
return CreatedAtRoute("DefaultApi", new { id = article.ArticleId }, article);
}
UPD:
[DataContract]
public class Article
{
[DataMember]
public int Id { get; set; }
[DataMember]
public string Summary { get; set; }
[DataMember]
[Column(TypeName = "ntext")]
public string Text { get; set; }
}