新聞中心
各種說(shuō)明Ado.Net代碼亂碼介紹問(wèn)題的開(kāi)發(fā)數(shù)據(jù)庫(kù)應(yīng)用程序,常規(guī)時(shí)都不直接對(duì)數(shù)據(jù)庫(kù)操作,而是先完成數(shù)據(jù)連接和通過(guò)數(shù)據(jù)適配器填充DataSet對(duì)象,然后客戶端再通過(guò)讀取DataSet來(lái)獲得需要的數(shù)據(jù),

創(chuàng)新互聯(lián)成立于2013年,是專業(yè)互聯(lián)網(wǎng)技術(shù)服務(wù)公司,擁有項(xiàng)目做網(wǎng)站、網(wǎng)站制作網(wǎng)站策劃,項(xiàng)目實(shí)施與項(xiàng)目整合能力。我們以讓每一個(gè)夢(mèng)想脫穎而出為使命,1280元魯山做網(wǎng)站,已為上家服務(wù),為魯山各地企業(yè)和個(gè)人服務(wù),聯(lián)系電話:18982081108
ADO.NET,首先必須了解、掌握DataSet。DataSet主要有三個(gè)特性:
1. 獨(dú)立性。DataSet獨(dú)立于各種數(shù)據(jù)源。微軟公司在推出DataSet時(shí)就考慮到各種數(shù)據(jù)源的多樣性、復(fù)雜性。在Ado.Net代碼中,無(wú)論什么類型數(shù)據(jù)源,Ado.Net代碼都會(huì)提供一致的關(guān)系編程模型,而這就是DataSet。#t#
2. 離線(斷開(kāi))和連接。DataSet既可以以離線方式,也可以以實(shí)時(shí)連接來(lái)操作數(shù)據(jù)庫(kù)中的數(shù)據(jù)。這一點(diǎn)有點(diǎn)像ADO中的RecordSet。
3. DataSet對(duì)象是一個(gè)可以用XML形式表示的數(shù)據(jù)視圖,是一種數(shù)據(jù)關(guān)系視圖。
這樣子寫Ado.Net代碼,執(zhí)行以后數(shù)據(jù)庫(kù)中中文字符顯示亂碼,PS:Article_Subject 為NCHAR,Article_Content 為Ntext
- strSql = "INSERT INTO Articles ([Article_Subject] ,[Article_Content] ,[Author_ID] ,[Post_Time])
- ALUES ('測(cè)試','測(cè)試','FrancisLiu','"+DateTime.Today.ToShortDateString()+"')";
- SqlCommand cmd = new SqlCommand();
- cmd.Connection = conn;
- cmd.CommandText = strSql;
- cmd.ExecuteNonQuery();
- 用 SqlParameter沒(méi)問(wèn)題的
- 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;
新聞標(biāo)題:說(shuō)明Ado.Net代碼亂碼介紹問(wèn)題
網(wǎng)頁(yè)鏈接:http://www.dlmjj.cn/article/cdjhjed.html


咨詢
建站咨詢
