У меня есть текстовая область на моей странице. В этой области я должен добавить HTML-код и сохранить его в базе данных. И это работает для простого HTML, но когда я выбираю какой-то текст из «Википедии», например, вставляю его и пытаюсь сохранить, когда нужно выполнить SQL-запрос, я получил исключение со следующей ошибкой:
Incorrect syntax near 's'.
The identifier that starts with '. Interestingly, old maps show the name as <em>Krakow</em>.</p>
<p>Kragujevac experienced a lot of historical turbulence, ' is too long. Maximum length is 128.
The identifier that starts with '>Paleolithic</a> era. Kragujevac was first mentioned in the medieval period as related to the public square built in a sett' is too long. Maximum length is 128.
The label 'http' has already been declared. Label names must be unique within a query batch or stored procedure.
The label 'http' has already been declared. Label names must be unique within a query batch or stored procedure.
Unclosed quotation mark after the character string '>Belgrade Pashaluk</a>.</p>'
Я использую asp mvc и бритву. Я не знаю, может быть, мне нужно каким-то образом получить HTML. Я также добавил это для свойства ArticleText:
[AllowHtml]
public string ArticleText { get; set; }
Это код для сохранения в базе данных:
string sql = @"insert into tbl_articles
(Text) values
("'" + article.ArticleText"'"+")";
SqlCommand cmd = new SqlCommand(sql, conn);
cmd.ExecuteNonQuery();