In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-03 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
This article mainly introduces "how to solve the Ado.Net garbled problem". In the daily operation, I believe many people have doubts about how to solve the Ado.Net garbled problem. The editor consulted all kinds of materials and sorted out simple and easy-to-use operation methods. I hope it will be helpful for everyone to answer the doubt of "how to solve the Ado.Net garbled problem"! Next, please follow the editor to study!
In general, all kinds of database applications that explain the problem of Ado.Net code introduction do not operate directly on the database, but first complete the data connection and populate the DataSet object through the data adapter, and then the client reads the DataSet to get the needed data.
ADO.NET, first of all, we must understand and master DataSet. DataSet has three main features:
1. Independence. DataSet is independent of various data sources. When Microsoft launched DataSet, it considered the diversity and complexity of various data sources. In Ado.Net code, regardless of the type of data source, Ado.Net code provides a consistent relational programming model, and this is DataSet.
two。 Offline (disconnected) and connected. DataSet can manipulate data in the database either offline or with a real-time connection. This is a bit like RecordSet in ADO.
3. The DataSet object is a data view that can be represented in the form of XML, and it is a data relational view.
If you write the Ado.Net code in this way, the Chinese characters in the database will be garbled after execution, and the PS:Article_Subject will be NCHAR,Article_Content and Ntext.
StrSql = "INSERT INTO Articles ([Article_Subject], [Article_Content], [Author_ID], [Post_Time])
ALUES ('test', 'test', 'FrancisLiu',' "+ DateTime.Today.ToShortDateString () +"') "
SqlCommand cmd = new SqlCommand ()
Cmd.Connection = conn
Cmd.CommandText = strSql
Cmd.ExecuteNonQuery ()
It's no problem to use SqlParameter.
StrSql.Append ("insert into [Articles] (")
StrSql.Append ("[article_Subject], [article_Content] [author_id], [post_time])")
StrSql.Append ("values ("))
StrSql.Append ("@ article_Subject,@article_Content,@author_id,@make_time,@sReply_count)")
SqlParameter [] parameters = {
New SqlParameter (@ article_Subject, SqlDbType.NChar,40)
New SqlParameter (@ article_Content, SqlDbType.NText)
New SqlParameter (@ author_id, SqlDbType.NChar,10)
New SqlParameter (@ make_time, SqlDbType.NChar,25)
Parameters [0] .value = model.article_Subject
Parameters [1] .value = model.article_Content
Model.make_time
At this point, the study on "how to solve the Ado.Net garbled problem" is over. I hope to be able to solve everyone's doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.