[已关闭问题]
这样子写,执行以后数据库中中文字符显示乱码,PS:<span style="color: rgb(128, 0, 0);">Article_Subject 为NCHAR,</span><span style="color: rgb(128, 0, 0);">Article_Content 为Ntext</span><span style="color: rgb(128, 0, 0);"> </span><div class="cnblogs_code"><!--<br><br>Code highlighting produced by Actipro CodeHighlighter (freeware)<br>http://www.CodeHighlighter.com/<br><br>--><img src="/Images/OutliningIndicators/None.gif" align="top"><span style="color: rgb(0, 0, 0);">strSql </span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(128, 0, 0);">"</span><span style="color: rgb(128, 0, 0);">INSERT INTO Articles ([Article_Subject] ,[Article_Content] ,[Author_ID] ,[Post_Time]) VALUES ('测试','测试','FrancisLiu','</span><span style="color: rgb(128, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">+</span><span style="color: rgb(0, 0, 0);">DateTime.Today.ToShortDateString()</span><span style="color: rgb(0, 0, 0);">+</span><span style="color: rgb(128, 0, 0);">"</span><span style="color: rgb(128, 0, 0);">')</span><span style="color: rgb(128, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">;<br><img src="/Images/OutliningIndicators/None.gif" align="top"> SqlCommand cmd </span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 255);">new</span><span style="color: rgb(0, 0, 0);"> SqlCommand();<br><img src="/Images/OutliningIndicators/None.gif" align="top">cmd.Connection </span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);"> conn;<br><img src="/Images/OutliningIndicators/None.gif" align="top">cmd.CommandText </span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);"> strSql;<br><img src="/Images/OutliningIndicators/None.gif" align="top">cmd.ExecuteNonQuery();<br>用 SqlParameter没问题的<br></span><div class="cnblogs_code"><!--<br><br>Code highlighting produced by Actipro CodeHighlighter (freeware)<br>http://www.CodeHighlighter.com/<br><br>--><img src="/Images/OutliningIndicators/None.gif" align="top"><span style="color: rgb(0, 0, 0);">strSql.Append(</span><span style="color: rgb(128, 0, 0);">"</span><span style="color: rgb(128, 0, 0);">insert into [Articles](</span><span style="color: rgb(128, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">);<br><img src="/Images/OutliningIndicators/None.gif" align="top"> strSql.Append(</span><span style="color: rgb(128, 0, 0);">"</span><span style="color: rgb(128, 0, 0);">[article_Subject],[article_Content],[author_id],[post_time])</span><span style="color: rgb(128, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">);<br><img src="/Images/OutliningIndicators/None.gif" align="top"> strSql.Append(</span><span style="color: rgb(128, 0, 0);">"</span><span style="color: rgb(128, 0, 0);"> values (</span><span style="color: rgb(128, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">);<br><img src="/Images/OutliningIndicators/None.gif" align="top"> strSql.Append(</span><span style="color: rgb(128, 0, 0);">"</span><span style="color: rgb(128, 0, 0);">@article_Subject,@article_Content,@author_id,@make_time,@sReply_count)</span><span style="color: rgb(128, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">);<br><img src="/Images/OutliningIndicators/ExpandedBlockStart.gif" id="Codehighlighter1_304_634_Open_Image" onclick="this.style.display='none'; document.getElementById('Codehighlighter1_304_634_Open_Text').style.display='none'; document.getElementById('Codehighlighter1_304_634_Closed_Image').style.display='inline'; document.getElementById('Codehighlighter1_304_634_Closed_Text').style.display='inline';" align="top"><img src="/Images/OutliningIndicators/ContractedBlock.gif" id="Codehighlighter1_304_634_Closed_Image" style="display: none;" onclick="this.style.display='none'; document.getElementById('Codehighlighter1_304_634_Closed_Text').style.display='none'; document.getElementById('Codehighlighter1_304_634_Open_Image').style.display='inline'; document.getElementById('Codehighlighter1_304_634_Open_Text').style.display='inline';" align="top"> SqlParameter[] parameters </span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);"> </span><span id="Codehighlighter1_304_634_Closed_Text" style="border: 1px solid rgb(128, 128, 128); background-color: rgb(255, 255, 255); display: none;"><img src="/images/dot.gif"></span><span id="Codehighlighter1_304_634_Open_Text"><span style="color: rgb(0, 0, 0);">{<br><img src="/Images/OutliningIndicators/InBlock.gif" align="top"> </span><span style="color: rgb(0, 0, 255);">new</span><span style="color: rgb(0, 0, 0);"> SqlParameter(</span><span style="color: rgb(128, 0, 0);">"</span><span style="color: rgb(128, 0, 0);">@article_Subject</span><span style="color: rgb(128, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">, SqlDbType.NChar,</span><span style="color: rgb(128, 0, 128);">40</span><span style="color: rgb(0, 0, 0);">),<br><img src="/Images/OutliningIndicators/InBlock.gif" align="top"> </span><span style="color: rgb(0, 0, 255);">new</span><span style="color: rgb(0, 0, 0);"> SqlParameter(</span><span style="color: rgb(128, 0, 0);">"</span><span style="color: rgb(128, 0, 0);">@article_Content</span><span style="color: rgb(128, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">, SqlDbType.NText),<br><img src="/Images/OutliningIndicators/InBlock.gif" align="top"> </span><span style="color: rgb(0, 0, 255);">new</span><span style="color: rgb(0, 0, 0);"> SqlParameter(</span><span style="color: rgb(128, 0, 0);">"</span><span style="color: rgb(128, 0, 0);">@author_id</span><span style="color: rgb(128, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">, SqlDbType.NChar,</span><span style="color: rgb(128, 0, 128);">10</span><span style="color: rgb(0, 0, 0);">),<br><img src="/Images/OutliningIndicators/InBlock.gif" align="top"> </span><span style="color: rgb(0, 0, 255);">new</span><span style="color: rgb(0, 0, 0);"> SqlParameter(</span><span style="color: rgb(128, 0, 0);">"</span><span style="color: rgb(128, 0, 0);">@make_time</span><span style="color: rgb(128, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">, SqlDbType.NChar,</span><span style="color: rgb(128, 0, 128);">25</span><span style="color: rgb(0, 0, 0);">)<br><img src="/Images/OutliningIndicators/InBlock.gif" align="top"> <br><img src="/Images/OutliningIndicators/ExpandedBlockEnd.gif" align="top"> }</span></span><span style="color: rgb(0, 0, 0);">;<br><img src="/Images/OutliningIndicators/None.gif" align="top"> parameters[</span><span style="color: rgb(128, 0, 128);">0</span><span style="color: rgb(0, 0, 0);">].Value </span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);"> model.article_Subject;<br><img src="/Images/OutliningIndicators/None.gif" align="top"> parameters[</span><span style="color: rgb(128, 0, 128);">1</span><span style="color: rgb(0, 0, 0);">].Value </span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);"> model.article_Content;<br><img src="/Images/OutliningIndicators/None.gif" align="top"> parameters[</span><span style="color: rgb(128, 0, 128);">2</span><span style="color: rgb(0, 0, 0);">].Value </span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);"> model.author_id;<br><img src="/Images/OutliningIndicators/None.gif" align="top"> parameters[</span><span style="color: rgb(128, 0, 128);">3</span><span style="color: rgb(0, 0, 0);">].Value </span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);"> model.make_time; <br></span></div><br><span style="color: rgb(0, 0, 0);"><br></span></div>用Linq to sql也是没问题的<br><br>