<input class="easyui-combobox" id="rwlb" name="rwlb" style="width:435px" data-options="valueField:'id', textField:'text', panelHeight:'auto'" >
鏂規(guī)硶涓€錛?/p>
1 var data, json; 2 json = '[{"id":"騫磋鍒?,"text":"騫磋鍒?,"selected":true}]'; 3 data = $.parseJSON(json); 4 $("#rwlb").combobox("loadData", data);
鏂規(guī)硶浜岋細(xì)
1 var data,json; 2 data = []; 3 data.push({ "text": "嫻嬭瘯", "id": 100 }); 4 $("#rwlb").combobox("loadData", data);
Easyui Tree涓€鐩村氨娌℃湁鎻愪緵榪欎釜鏂規(guī)硶,浠ュ墠娌℃湁鐢ㄥ埌,鎵€浠ヤ竴鐩存病鎬庝箞鍦ㄦ剰,榪欐鑷繁鐢ㄥ埌浜?欏轟究鎵╁睍浜?jiǎn)涓€涓柟娉?鍒嗕韓緇欏ぇ瀹?
1 |
$.extend($.fn.tree.methods, { |
2 |
getLevel: function (jq,target){ |
3 |
var l = $(target).parentsUntil( "ul.tree" , "ul" ); |
4 |
return l.length+1; |
5 |
} |
6 |
}); |
1 |
var node = $().tree( "getSelected" ); |
2 |
var lv = $().tree( "getLevel" ,node.target); |
鍙傛暟榛樿鍊兼槸鎸囧湪璋冪敤鍑芥暟鏃訛紝鑻ョ渷鐣ヤ簡(jiǎn)鏌愪釜瀹炲弬錛屽嚱鏁頒細(xì)鑷姩涓鴻鍙傛暟鍒嗛厤涓€涓粯璁ゅ€鹼紝浣垮緱鍑芥暟璋冪敤鐨勬柟渚挎€у拰鐏墊椿鎬уぇ澶ф彁楂樸€?/p>
涓句釜渚嬪瓙錛屾瘮濡?a style="color: rgb(51,51,51); font-size: 14px; text-decoration: none" class="keylink" target="_blank">PHP涓殑瀛楃涓叉埅鍙栧嚱鏁皊ubstr(string,start,length)錛屽綋涓嶆寚瀹歭ength鏃訛紝鍑芥暟灝嗛粯璁ゆ埅鍙栧瓧絎︿覆涓璼tart浣嶇疆鍒板瓧絎︿覆緇撴潫錛岃€屽鏋滄寚瀹氫簡(jiǎn)length錛屽垯鎴彇浠巗tart浣嶇疆寮€濮嬬殑浠ength涓洪暱搴︾殑瀛楃涓詫紝鎵€浠ュ鏋滆皟鐢ㄧ殑鏄痵ubstr('http://www.hualai.net.cn',11,6)錛屽垯榪斿洖鐨勬槸hualai錛涘鏋滅渷鐣ユ帀鏈€鍚庝竴涓弬鏁幫紝substr('http://www.hualai.net.cn',11)錛屽垯榪斿洖hualai.net.cn銆?/p>
鍐嶆瘮濡俲Query妗嗘灦涓紝$(selector).html()鏂規(guī)硶鏄幏鍙栬鍏冪礌鍐呯殑HTML浠g爜錛岃€?(selector).html(content)鍒欐槸璁劇疆璇ュ厓绱犲唴鐨凥TML銆傛垜浠煡閬擄紝鍦–璇█涓紝鎴戜滑鍙互閫氳繃濡備笅褰㈠紡鏉ヤ負(fù)鍑芥暟鍙傛暟璁劇疆榛樿鍊鹼細(xì)
[cpp]
void foo(int a, int b = 1, bool c = false);
鍦?a style="color: rgb(51,51,51); font-size: 14px; text-decoration: none" class="keylink" target="_blank">Java涓紝鍒欏彲浠ラ€氳繃鍑芥暟閲嶈澆鏉ヨ緗嚱鏁板弬鏁伴粯璁ゅ€鹼細(xì)
[java]
public void foo(int a){
foo(a, 1);
}
public void foo(int a, int b){
foo(a, b, false);
}
public void foo(int a, int b, bool c){
//鍑芥暟鍐呭
}
鑰屽湪JavaScript涓紝濡備綍鍍廽Query閭f牱璁劇疆鍑芥暟鍙傛暟榛樿鍊煎憿錛烰avaScript涓茍娌℃湁鍍廋璇█涓畾涔夊嚱鏁版椂鐩存帴鍦ㄥ弬鏁板悗闈㈣祴鍊肩殑鏂規(guī)硶錛屼篃娌℃湁鍍廕ava閲岄偅鏍風(fēng)殑鍑芥暟閲嶈澆錛屼絾鎴戜滑鍙互閫氳繃JavaScript鏂規(guī)硶涓殑涓€涓猘rguments鍙鍙橀噺鏁扮粍鏉ュ疄鐜幫紝鍏蜂綋濡備笅錛?/p>
[js]
function foo(){
var a = arguments[0] ? arguments[0] : 1;
var b = arguments[1] ? arguments[1] : false;
//鍑芥暟鍐呭
}
浠ヤ笂鏄€氳繃鍒ゆ柇鍙傛暟鏄惁瀛樺湪錛岃嫢涓嶅瓨鍦ㄥ垯灝嗛粯璁ゅ€奸檮緇欏彉閲忥紝鑰屾垜浠彲浠ラ€氳繃鍒ゆ柇鍙傛暟鐨勭被鍨嬫潵瀹炵幇閲嶈澆錛?/p>
[js]
function foo(){
if(typeof arguments[0] == 'string')
alert('鍙傛暟綾誨瀷涓哄瓧絎︿覆');
else if(typeof arguments[0] == 'number')
alert('鍙傛暟綾誨瀷涓烘暟鍊?);
}
鎴栬€咃細(xì)
[js]
function foo(){
if(arguments[0].constructor == String)
alert('鍙傛暟綾誨瀷涓哄瓧絎︿覆');
else if(arguments[0].constructor == Number)
alert('鍙傛暟綾誨瀷涓烘暟鍊?);
}
鎰熻榪欎釜CTE閫掑綊鏌ヨ铔ソ鐢ㄧ殑錛屽厛涓句釜渚嬪瓙錛?/p>
涓婇潰鐨凷QL璇彞鍐嶆鎻掑叆涓€鏉℃暟鎹細(xì)
insert Tree values('緗戠粶1鐝?,'緗戠粶宸ョ▼')
榪愯緇撴灉濡備笅鍥撅細(xì)
鍥? 榪愯緇撴灉
娉ㄦ剰鐐癸細(xì)璨屼技鍦ㄩ€掑綊鎴愬憳澶勬墍閫夋嫨鐨勫瓧孌甸兘蹇呴』Tree琛ㄧ殑鏁版嵁錛岃€屼笉鑳芥槸CTE緇撴灉闆嗕腑鐨勯櫎浜?jiǎn)Tree涓病鏈夎€孋TE涓湁鐨勫瓧孌靛湪榪欓噷鎵嶅彲浠ュ紩鐢紝姣斿瀛楁TE銆?/p>
棣栧厛鐪嬩笅錛岄亶鍘嗙殑絎?鏉¤褰曠殑SQL璇彞錛?/p>
鑾峰彇鐨勭粨鏋滀負(fù)錛?/p>
Name Parent TE Levle
-------------------------------------
澶у NULL 澶у 0
閫掑綊絎?嬈℃墍鑾峰彇鐨勭粨鏋滈泦鍚堢殑綾籗QL璇彞涓猴細(xì)
涓婇潰鐨凜TE瀛愭煡璇㈢殑緇撴灉灝辨槸絎竴嬈¢€掑綊鏌ヨ鐨勭粨鏋滈泦錛屼笂闈QL榪愯緇撴灉涓猴細(xì)
鍚屾牱鐨勶紝灝嗙浜屾閫掑綊鏌ヨ鐨勪笂闈笁鏉¤褰曚綔涓虹涓夋鏌ヨ鐨?#8216;瀹氫綅鎴愬憳’錛?/p>
銆愯繖閲岃娉ㄦ剰錛屼笂闈㈢殑涓夋潯璁板綍鏄粠鏈€鍚庝竴鏉″紑濮嬩緷嬈′綔涓虹涓夋閫掑綊鐨勮緭鍏ョ殑錛屽嵆絎竴鏉℃槸ID=9鐨勮褰曪紝鎺ヤ笅鏉ユ槸7鍜?錛屽叧浜庣鍥涙閫掑綊涔熺被浼箋€?/p>
絎笁嬈¢€掑綊綾籗QL璇彞
緇撴灉濡備笅錛?/p>
鍏跺疄姣忔閫掑綊鐨勭被SQL鍙負(fù)濡備笅鎵€紺猴細(xì)
絎洓嬈¢€掑綊涓€嬈$被鎺紝鏈€鍚庢墍鏌ヨ鐨勭粨鏋滀負(fù)涓婇潰鎵€鏈夐€掑綊鐨剈nion銆?/p>
緇細(xì)鍦ㄤ笂闈㈢殑SQ璇彞鏌ヨ緇撴灉涓紝ID涓?0鐨勮褰曞簲璇ヨ鏀懼湪ID涓?鐨勫悗闈€€?/p>
寰€鏁版嵁琛ㄤ腑鍐嶆娣誨姞涓ゆ潯璁板綍錛?/p>
insert Tree values('璁$','璁$畻鏈哄闄?)
insert Tree values('鎴?,'緗戠粶1鐝?)
鍐嶆淇敼涓婇潰鐨凷QL璇彞錛?/p>
鏈€鍚庣殑緇撴灉涓猴細(xì)
鍥? 榪愯緇撴灉
榪欐牱錛屾棤璁虹敤鎴鋒彃鍏ュ灝戞潯璁板綍閮藉彲浠ヨ繘琛屾寜閮ㄩ棬錛屾寜瑙勫緥榪涜鏌ヨ銆?/p>
BLL灞?nbsp;
public void Update(DataTable dt)
{
foreach (DataRow dr in dt.Rows)
{
if (dr.RowState == DataRowState.Deleted)
continue;
if (dr.RowState == DataRowState.Modified || dr.RowState == DataRowState.Added)
{
if (dr["usr_id"] == DBNull.Value)
{
throw new Exception("鐢ㄦ埛浠g爜涓嶈兘涓虹┖");
} }
}
dal.Update(dt);
}
DAL灞?/p>
public void Update(DataTable dt)
{
SqlDataAdapter adapter = new SqlDataAdapter();
SqlConnection conn = new SqlConnection(SqlHelper.ConnectionString);
conn.Open();
adapter.InsertCommand = new SqlCommand("INSERT INTO dbo.t6( com_id ,usr_id ) VALUES( @com_id ,@usr_id)", conn);
adapter.InsertCommand.CommandType = CommandType.Text;
adapter.InsertCommand.Parameters.Add("@com_id", SqlDbType.VarChar, 4, "com_id");
adapter.InsertCommand.Parameters.Add("@usr_id", SqlDbType.VarChar, 8, "usr_id");
adapter.UpdateCommand = new SqlCommand("update t6 setwhereand usr_id", conn);
adapter.UpdateCommand.CommandType = CommandType.Text;
adapter.UpdateCommand.Parameters.Add("@com_id", SqlDbType.VarChar, 4, "com_id");
adapter.UpdateCommand.Parameters.Add("@usr_id", SqlDbType.VarChar, 8, "usr_id");
adapter.UpdateCommand.Parameters.Add("@usr_id1", SqlDbType.VarChar, 8, "usr_id");
adapter.UpdateCommand.Parameters["@usr_id1"].SourceVersion = DataRowVersion.Original;
adapter.DeleteCommand = new SqlCommand("delete from t6 whereand usr_id", conn);
adapter.DeleteCommand.CommandType = CommandType.Text;
adapter.DeleteCommand.Parameters.Add("@com_id", SqlDbType.VarChar, 4, "com_id");
adapter.DeleteCommand.Parameters.Add("@usr_id", SqlDbType.VarChar, 8, "usr_id");
adapter.DeleteCommand.Parameters["@com_id"].SourceVersion = DataRowVersion.Original;
adapter.DeleteCommand.Parameters["@usr_id"].SourceVersion = DataRowVersion.Original;
adapter.Update(dt);
}
鍓嶅彴
public partial class DataTableUpdate : Form
{
public BLL.Users Bu = new BLL.Users();
public DataTable dtUsr = new DataTable();
public MOD.Users modObject = new MOD.Users();
public string _UserId = "";
public DataTableUpdate()
{
InitializeComponent();
dataGridView1.AutoGenerateColumns = false;
}
//紿楀彛鍔犺澆
private void Form1_Load(object sender, EventArgs e)
{
dtUsr = Bu.GetList();
dataGridView1.DataSource = dtUsr;
BindValue();
}
private void BindValue()
{
tb_com_id.DataBindings.Add("Text", dataGridView1.DataSource, "com_id");
tb_UsrId.DataBindings.Add("Text", dataGridView1.DataSource, "usr_id");
//鎵嬪姩淇敼鍙互; 浠g爜璧嬪€奸渶瑕佺敤涓嬮潰榪欏彞璇?br /> tb_UsrId.DataBindings[0].DataSourceUpdateMode = DataSourceUpdateMode.OnPropertyChanged;
}
private void 淇濆瓨_Click(object sender, EventArgs e)
{
foreach (DataRow dr in dtUsr.Rows)
{
dr.EndEdit();
}
try
{
Bu.Update(dtUsr);
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
return;
}
MessageBox.Show("淇濆瓨鎴愬姛錛?, "緋葷粺鎻愮ず");
}
private void 鍒犻櫎_Click(object sender, EventArgs e)
{
if (MessageBox.Show("鎮(zhèn)ㄧ‘璁よ鍒犻櫎鐢ㄦ埛錛? + tb_UsrName.Text.Trim()+" ?", "鎻愮ず", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2) == DialogResult.No)
return;
if (dataGridView1.CurrentCell == null)
return;
try
{
dataGridView1.Rows.Remove(dataGridView1.CurrentRow);
Bu.Update(dtUsr);
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
return;
}
MessageBox.Show("鍒犻櫎鎴愬姛錛?, "緋葷粺鎻愮ず");
}
private void 澧炲姞_Click(object sender, EventArgs e)
{
DataRow dr = dtUsr.NewRow();
dr["usr_id"] = _UserId;
dtUsr.Rows.Add(dr);
dataGridView1.CurrentCell = dataGridView1.Rows[dataGridView1.Rows.Count - 1].Cells[0];
}
private void 鍙栨秷_Click(object sender, EventArgs e)
{
dtUsr.RejectChanges();
}
鐗涢搧錛?a style="color: rgb(63,167,203); text-decoration: underline" >http://blog.csdn.net/fangxinggood/archive/2008/04/18/2304047.aspx
鏈妭鍐呭
灝嗘暟鎹坊鑷寵〃涓?/font>:璇存槑濡備綍鍒涘緩鏂拌騫跺皢鍏舵坊鑷寵〃涓€?/p>
浠ヤ笅紺轟緥婕旂ず浜?jiǎn)濡備綍閫氳繃璋冪敤 NewRow 鏂規(guī)硶鏉ュ垱寤烘柊琛屻€?/p>
DataRow workRow = workTable.NewRow(); 鐒跺悗鎮(zhèn)ㄥ彲浠ヤ嬌鐢ㄧ儲(chǔ)寮曟垨鍒楀悕鏉ユ搷浣滄柊娣誨姞鐨勮錛屽涓嬩緥鎵€紺恒€?/p>
workRow["CustLName"] = "Smith"; 鍦ㄥ皢鏁版嵁鎻掑叆鏂拌鍚庯紝Add 鏂規(guī)硶鍙敤浜庡皢琛屾坊鑷?span class="Apple-converted-space"> DataRowCollection錛屽浠ヤ笅浠g爜鎵€紺恒€?/p>
workTable.Rows.Add(workRow); 鎮(zhèn)ㄤ篃鍙互閫氳繃浼犲叆鍊肩殑鏁扮粍錛堢被鍨嬪寲涓?span class="Apple-converted-space"> Object錛夛紝璋冪敤 Add 鏂規(guī)硶鏉ユ坊鍔犳柊琛岋紝濡備笅渚嬫墍紺恒€?/p>
workTable.Rows.Add(new Object[] {1, "Smith"}); 灝嗙被鍨嬪寲涓?span class="Apple-converted-space"> Object 鐨勫€肩殑鏁扮粍浼犻€掑埌 Add 鏂規(guī)硶錛屽彲鍦ㄨ〃鍐呭垱寤烘柊琛屽茍灝嗗叾鍒楀€艱緗負(fù)瀵硅薄鏁扮粍涓殑鍊箋€傝娉ㄦ剰錛屾暟緇勪腑鐨勫€間細(xì)鏍規(guī)嵁瀹冧滑鍦ㄨ〃涓嚭鐜扮殑欏哄簭鐩哥戶(hù)涓庡悇鍒楀尮閰嶃€?/p>
浠ヤ笅紺轟緥灝嗗崄琛屾坊鑷蟲(chóng)柊寤虹殑 Customers 琛ㄤ腑銆?/p>
DataRow workRow;
鍦ㄥ垱寤?span class="Apple-converted-space"> DataTable 騫朵嬌鐢ㄥ垪鍜岀害鏉熷畾涔夊叾緇撴瀯涔嬪悗錛屾?zhèn)ㄥ彲浠畣鏂扮殑鏁版嵁琛屾坊鑷宠〃涓€傝娣誨姞鏂拌錛屽彲灝嗕竴涓柊鍙橀噺澹版槑涓?span class="Apple-converted-space"> DataRow 綾誨瀷銆傝皟鐢?span class="Apple-converted-space"> NewRow 鏂規(guī)硶鏃訛紝灝嗚繑鍥炴柊鐨?span class="Apple-converted-space"> DataRow 瀵硅薄銆傜劧鍚庯紝DataTable 浼?xì)鏍规嵁琛ㄧ殑缁撴瀯鎸?span id="wmqeeuq" class="Apple-converted-space"> DataColumnCollection 鐨勫畾涔夊垱寤?span class="Apple-converted-space"> DataRow 瀵硅薄銆?
workRow[1] = "Smith";
for (int i = 0; i <= 9; i++)
{
workRow = workTable.NewRow();
workRow[0] = i;
workRow[1] = "CustName" + i.ToString();
workTable.Rows.Add(workRow);
}
鏌ョ湅琛ㄤ腑鏁版嵁:璇存槑濡備綍璁塊棶琛屼腑鐨勬暟鎹紝鍖呮嫭鏁版嵁鐨勫師濮嬬増鏈拰褰撳墠鐗堟湰銆?/p>
DataTable 瀵硅薄鐨?span class="Apple-converted-space"> Select 鏂規(guī)硶榪斿洖涓€緇勪笌鎸囧畾鏉′歡鍖歸厤鐨?span class="Apple-converted-space"> DataRow 瀵硅薄銆?strong>Select 閲囩敤絳涢€夎〃杈懼紡銆佹帓搴忚〃杈懼紡鍜?span class="Apple-converted-space"> DataViewRowState 鐨勫彲閫夊弬鏁般€傜瓫閫夎〃杈懼紡鏍規(guī)嵁 DataColumn 鍊鹼紙渚嬪 Select 鏂規(guī)硶鍩轟簬 DataViewRowState 紜畾瑕佹煡鐪嬫垨鎿嶄綔鐨勮鐨勭増鏈€備笅琛ㄨ鏄庝簡(jiǎn)鍙兘鐨?span class="Apple-converted-space"> DataViewRowState 鏋氫婦鍊箋€?/p>
鍦ㄤ笅闈㈢殑紺轟緥涓紝DataSet 瀵硅薄宸茬粡榪囩瓫閫夛紝榪欐牱錛屾?zhèn)ㄥ彲浠ュ彧鋴社敤鍏?span id="wmqeeuq" class="Apple-converted-space"> DataViewRowState 璁劇疆涓?span class="Apple-converted-space"> CurrentRows鐨勮銆?/p>
DataRow[] currRows = workTable.Select(null, null, DataViewRowState.CurrentRows); Select 鏂規(guī)硶鍙敤浜庤繑鍥炲叿鏈変笉鍚?span class="Apple-converted-space"> RowState 鍊兼垨瀛楁鍊肩殑琛屻€備互涓嬬ず渚嬭繑鍥炰竴涓紩鐢ㄦ墍鏈夊凡鍒犻櫎琛岀殑 DataRow鏁扮粍錛屽茍榪斿洖鍙︿竴涓紩鐢ㄦ墍鏈夊凡鎺掑簭琛岋紙鎸夌収 CustLName 鎺掑簭錛屽叾涓?span class="Apple-converted-space"> CustID 鍒楀ぇ浜?5錛夌殑 DataRow 鏁扮粍銆?/p>
// Retrieve all deleted rows.
鍙互浣跨敤 DataTable 鐨?span class="Apple-converted-space"> Rows 鍜?span class="Apple-converted-space"> Columns 闆嗗悎鏉ヨ闂?span class="Apple-converted-space"> DataTable 涓殑鍐呭銆備篃鍙互鏍規(guī)嵁鍖呮嫭鎼滅儲(chǔ)鏍囧噯銆佹帓搴忛『搴忓拰琛岀姸鎬佺瓑鐗瑰畾鏍囧噯錛屼嬌鐢?span class="Apple-converted-space"> DataTable.Select 鏂規(guī)硶榪斿洖 DataTable 涓暟鎹殑瀛愰泦銆傛澶栵紝鐢ㄤ富閿€兼悳绱㈢壒瀹氳鏃訛紝榪樺彲浣跨敤 DataRowCollection 鐨?span class="Apple-converted-space"> LastName = 'Smith'
銆傛帓搴忚〃杈懼紡閬靛驚鐢ㄤ簬涓哄垪鎺掑簭鐨勬爣鍑?SQL 綰﹀畾錛屼緥濡?span class="Apple-converted-space"> LastName ASC, FirstName ASC
銆傛湁鍏崇紪鍐欒〃杈懼紡鐨勮鍒欙紝璇峰弬闃?strong>DataColumn 綾葷殑 鎻愮ず 濡傛灉鎮(zhèn)ㄥ皢瀵?span class="Apple-converted-space"> DataTable 鐨?span class="Apple-converted-space"> Select 鏂規(guī)硶鎵ц澶氭璋冪敤錛屽彲閫氳繃鍏堜負(fù) DataTable 鍒涘緩 DataView鏉ユ彁楂樻€ц兘銆傚垱寤?span class="Apple-converted-space"> DataView 浼?xì)湄?fù)琛ㄤ腑鐨勮緙栧埗绱㈠紩銆傜劧鍚庯紝Select 鏂規(guī)硶浼?xì)鋴社敤璇ョ储寮曞Q岃繖鏍峰皢鏄捐憲緙╃煭鐢熸垚鏌ヨ緇撴灉鐨勬椂闂淬€傛湁鍏充負(fù) DataTable 鍒涘緩 DataView 鐨勪俊鎭紝璇峰弬闃?a style="color: rgb(51,102,153); text-decoration: none" >鍒涘緩鍜屼嬌鐢?DataView銆?/blockquote>
鎴愬憳鍚嶇О
璇存槑
CurrentRows
褰撳墠琛岋紝鍖呮嫭鏈洿鏀圭殑琛屻€佸凡娣誨姞鐨勮鍜屽凡淇敼鐨勮銆?/td>
Deleted
宸插垹闄ょ殑琛屻€?/td>
ModifiedCurrent
褰撳墠鐗堟湰錛屽畠鏄師濮嬫暟鎹殑淇敼鐗堟湰錛堣鍙傞槄ModifiedOriginal錛夈€?/td>
ModifiedOriginal
鎵€鏈夊凡淇敼琛岀殑鍘熷鐗堟湰銆備嬌鐢?span class="Apple-converted-space"> ModifiedCurrent 鏃訛紝褰撳墠鐗堟湰鍙敤銆?/td>
Added
鏂拌銆?/td>
None
鏃犮€?/td>
OriginalRows
鍘熷琛岋紝鍖呮嫭鏈洿鏀圭殑琛屽拰宸插垹闄ょ殑琛屻€?/td>
Unchanged
鏈洿鏀圭殑琛屻€?/td>
if (currRows.Length < 1 )
Console.WriteLine("No Current Rows Found");
else
{
foreach (DataColumn myCol in workTable.Columns)
Console.Write("/t{0}", myCol.ColumnName);
Console.WriteLine("/tRowState");
foreach (DataRow myRow in currRows)
{
foreach (DataColumn myCol in workTable.Columns)
Console.Write("/t{0}", myRow[myCol]);
Console.WriteLine("/t" + myRow.RowState);
}
}
DataRow[] delRows = workTable.Select(null, null, DataViewRowState.Deleted);
// Retrieve rows where CustID > 5, and order by CustLName.
DataRow[] custRows = workTable.Select("CustID > 5", "CustLName ASC");
緙栬緫琛ㄤ腑鐨勬暟鎹?/font>:璇存槑濡備綍淇敼琛屼腑鐨勬暟鎹紝鍖呮嫭鎸傝搗瀵硅鐨勬洿鏀癸紝鐩磋嚦楠岃瘉騫舵帴鍙椾簡(jiǎn)寤鴻鐨勬洿鏀廣€?/p>
褰撴?zhèn)ㄧ洿鎺ュ?span class="Apple-converted-space"> DataRow 涓慨鏀瑰垪鍊兼椂錛?strong>DataRow 浼?xì)鋴社?span class="Apple-converted-space"> Current銆?strong>Default 鍜?span class="Apple-converted-space"> Original 琛岀増鏈潵綆$悊鍒楀€箋€傞櫎榪欎簺琛岀増鏈互澶栵紝BeginEdit銆?strong>EndEdit 鍜?span class="Apple-converted-space"> CancelEdit 鏂規(guī)硶榪樹(shù)嬌鐢ㄧ鍥涗釜琛岀増鏈細(xì)Proposed銆?/p>
鍦ㄦ墽琛岀紪杈戞搷浣滐紙閫氳繃璋冪敤 BeginEdit 寮€濮嬶紝騫朵笖閫氳繃浣跨敤 EndEdit 鎴?span class="Apple-converted-space"> CancelEdit 鎴栬€呴€氳繃璋冪敤AcceptChanges 鎴?span class="Apple-converted-space"> RejectChanges 緇撴潫錛夌殑榪囩▼涓紝Proposed 琛岀増鏈細(xì)瀛樺湪銆?/p>
鍦ㄧ紪杈戞搷浣滆繃紼嬩腑錛屾?zhèn)ㄥ彲浠ラ€氳繃璁$畻 DataTable 鐨?span class="Apple-converted-space"> ColumnChanged 浜嬩歡涓殑 ProposedValue 鏉ュ皢楠岃瘉閫昏緫搴旂敤浜庡悇鍒椼€?strong>ColumnChanged 浜嬩歡淇濆瓨 DataColumnChangeEventArgs錛屽彲淇濇寔瀵規(guī)鍦ㄦ洿鏀圭殑鍒楀拰ProposedValue 鐨勫紩鐢ㄣ€傝綆椾簡(jiǎn)寤鴻鍊煎悗錛屽彲浠ュ鍏惰繘琛屼慨鏀規(guī)垨鍙栨秷緙栬緫銆傜紪杈戠粨鏉熸椂錛岃浠?span class="Apple-converted-space"> Proposed 鐘舵€佷腑縐誨嚭銆?/p>
鎮(zhèn)ㄥ彲浠ラ€氳繃璋冪敤 EndEdit 鏉ョ‘璁ょ紪杈戯紝涔熷彲浠ラ€氳繃璋冪敤 CancelEdit 鏉ュ彇娑堢紪杈戙€傝娉ㄦ剰錛屽敖綆?span class="Apple-converted-space"> EndEdit 紜疄宸茬‘璁ゆ?zhèn)ㄦ墍鍋氱殑緙栬緫錛屼絾鍦ㄨ皟鐢?span class="Apple-converted-space"> AcceptChanges 涔嬪墠錛?strong>DataSet 騫舵病鏈夊疄闄呮帴鍙楁洿鏀廣€傚彟澶栬娉ㄦ剰錛屽鏋滃湪EndEdit 鎴?span class="Apple-converted-space"> CancelEdit 緙栬緫緇撴潫涔嬪墠璋冪敤 AcceptChanges錛岀紪杈戝皢浼?xì)缁堟锛岒q舵帴鍙?span class="Apple-converted-space"> Current 鍜?span class="Apple-converted-space"> Original 琛岀増鏈殑 Proposed 琛屽€箋€傝皟鐢?span class="Apple-converted-space"> RejectChanges 浼?xì)浠ュ悓鏍风殑鏂瑰紡缁撴潫缂栬緫锛岒q舵斁寮?span class="Apple-converted-space"> Current 鍜?span class="Apple-converted-space"> Proposed 琛岀増鏈€傚湪璋冪敤 AcceptChanges 鎴?span class="Apple-converted-space"> RejectChanges 涔嬪悗璋冪敤 EndEdit 鎴?span class="Apple-converted-space"> CancelEdit 涓嶄細(xì)璧蜂綔鐢紝鍥犱負(fù)緙栬緫宸茬粡緇撴潫銆?/p>
浠ヤ笅紺轟緥婕旂ず浜?jiǎn)濡備綍灏?span id="wmqeeuq" class="Apple-converted-space"> BeginEdit 涓?span class="Apple-converted-space"> EndEdit 鍜?span class="Apple-converted-space"> CancelEdit 涓€璧蜂嬌鐢ㄣ€傛湰紺轟緥涔熶細(xì)媯€(gè)鏌?span class="Apple-converted-space"> ColumnChanged 浜嬩歡涓殑 ProposedValue錛屽茍鍐沖畾鏄惁鍙栨秷緙栬緫銆?/p>
DataTable workTable = new DataTable();
褰撴?zhèn)ㄥ?span class="Apple-converted-space"> DataRow 涓洿鏀瑰垪鍊兼椂錛屾墍鍋氭洿鏀逛細(xì)绔嬪嵆緗簬琛岀殑 Current 鐘舵€佷腑銆傜劧鍚庯紝RowState 浼?xì)璁揪|負(fù)Modified錛屽茍浣跨敤 DataRow 鐨?span class="Apple-converted-space"> AcceptChanges 鎴?span class="Apple-converted-space"> RejectChanges 鏂規(guī)硶鏉ユ帴鍙楁垨鎷掔粷鎵€鍋氭洿鏀廣€?strong>DataRow榪樻彁渚涗簡(jiǎn)涓夌鍙敤浜庡湪緙栬緫琛屾椂灝嗚鐨勭姸鎬佹寕璧風(fēng)殑鏂規(guī)硶銆傝繖浜涙柟娉曟槸 BeginEdit銆?strong>EndEdit 鍜?span class="Apple-converted-space"> CancelEdit銆?
workTable.Columns.Add("LastName", typeof(String));
workTable.ColumnChanged += new DataColumnChangeEventHandler(OnColumnChanged);
DataRow workRow = workTable.NewRow();
workRow[0] = "Smith";
workTable.Rows.Add(workRow);
workRow.BeginEdit();
// Causes the ColumnChanged event to write a message and cancel the edit.
workRow[0] = "";
workRow.EndEdit();
// Displays "Smith, New".
Console.WriteLine("{0}, {1}", workRow[0], workRow.RowState);
protected static void OnColumnChanged(Object sender, DataColumnChangeEventArgs args)
{
if (args.Column.ColumnName == "LastName")
if (args.ProposedValue.ToString() == "")
{
Console.WriteLine("Last Name cannot be blank. Edit canceled.");
args.Row.CancelEdit();
}
}
琛岀姸鎬佷笌琛岀増鏈?/font>:鎻愪緵鏈夊叧琛岀殑涓嶅悓鐘舵€佺殑淇℃伅銆?/p>
姣忎釜 DataRow 瀵硅薄閮藉叿鏈?span class="Apple-converted-space"> RowState 灞炴€э紝鎮(zhèn)ㄥ彲浠ユ鏌ユ灞炴€ф潵紜畾琛岀殑褰撳墠鐘舵€併€備笅琛ㄧ粰鍑轟簡(jiǎn)瀵瑰悇RowState 鏋氫婦鍊肩殑綆€瑕佽鏄庛€?/p>
瀵逛簬宸茬粡浣跨敤 Remove 鏂規(guī)硶錛堟垨鏄湪浣跨敤 Delete 鏂規(guī)硶涔嬪悗浣跨敤浜?span class="Apple-converted-space"> AcceptChanges 鏂規(guī)硶錛変粠DataRowCollection 涓Щ闄ょ殑琛岋紝涔熻緗負(fù) Detached銆?/p> 鍦?span class="Apple-converted-space"> DataSet銆?strong>DataTable 鎴?span class="Apple-converted-space"> DataRow 涓婅皟鐢?span class="Apple-converted-space"> AcceptChanges 鏃訛紝浼?xì)绉婚櫎琛岀姸鎬佷負(fù) Deleted 鐨勬墍鏈夎銆傚墿浣欑殑琛屼細(xì)琚祴浜?span class="Apple-converted-space"> Unchanged 琛岀姸鎬侊紝騫朵笖 Original 琛岀増鏈腑鐨勫€間細(xì)鏀瑰啓涓?span class="Apple-converted-space"> Current 琛岀増鏈€箋€傝皟鐢?strong>RejectChanges 鏃訛紝浼?xì)绉婚櫎琛岀姸鎬佷負(fù) Added 鐨勬墍鏈夎銆傚墿浣欑殑琛屼細(xì)琚祴浜?span class="Apple-converted-space"> Unchanged 鐨勮鐘舵€侊紝騫朵笖Current 琛岀増鏈腑鐨勫€間細(xì)鏀瑰啓涓?span class="Apple-converted-space"> Original 琛岀増鏈€箋€?/p>
閫氳繃鐢ㄥ垪寮曠敤鏉ヤ紶閫?span class="Apple-converted-space"> DataRowVersion 鍙傛暟錛屾?zhèn)ㄥ彲浠ユ煡鐪嬭鐨勪笉鍚岃鐗堟湰锛屽涓嬩緥鎵€紺恒€?/p>
DataRow custRow = custTable.Rows[0]; 涓嬭〃緇欏嚭浜?jiǎn)鍚?span id="wmqeeuq" class="Apple-converted-space"> DataRowVersion 鏋氫婦鍊肩殑綆€瑕佽鏄庛€?/p>
閫氳繃璋冪敤 HasVersion 鏂規(guī)硶騫跺皢 DataRowVersion 浣滀負(fù)鍙傛暟浼犻€掞紝鎮(zhèn)ㄥ彲浠ユ祴璇?span class="Apple-converted-space"> DataRow 鏄惁鍏鋒湁鐗瑰畾鐨勮鐗堟湰銆備緥濡傦紝鍦ㄨ皟鐢?span class="Apple-converted-space"> AcceptChanges 涔嬪墠錛?code class="ce">DataRow.HasVersion(DataRowVersion.Original) 瀵規(guī)柊娣誨姞鐨勮灝嗚繑鍥?span class="Apple-converted-space"> false銆?/p>
渚嬪錛屼互涓嬩唬鐮佺ず渚嬫樉紺轟簡(jiǎn)琛ㄤ腑鎵€鏈夊凡鍒犻櫎琛岀殑鍊箋€傚凡鍒犻櫎鐨勮娌℃湁 Current 琛岀増鏈紝鍥犳鍦ㄨ闂垪鍊兼椂蹇呴』浼犻€?span class="Apple-converted-space"> DataRowVersion.Original銆?/p>
DataTable catTable = catDS.Tables["Categories"];
ADO.NET 鐢ㄨ鐘舵€佸拰鐗堟湰綆$悊琛ㄤ腑鐨勮銆傝鐘舵€佽〃紺鴻鐨勭姸鎬併€傚綋淇敼琛屾椂錛岃鐗堟湰浼?xì)缁存姢瀛樺偍浜庤涓殑鍊鹼紝鍖呮嫭褰撳墠鍊箋€佸師濮嬪€煎拰榛樿鍊箋€備緥濡傦紝淇敼浜?jiǎn)鏌愯涓殑涓€鍒楀悗錛岃琛屼細(xì)鏈変竴涓?span class="Apple-converted-space"> Modified 鐨勮鐘舵€侊紝騫朵笖浼?xì)瀛樺湪涓や釜琛岀増鏈Q?strong>Current錛堝寘鍚綋鍓嶈鍊鹼級(jí)鍜?span class="Apple-converted-space"> Original錛堝寘鍚慨鏀硅鍒楀墠鐨勮鍊鹼級(jí)銆?
RowState
璇存槑
Unchanged
鑷笂嬈¤皟鐢?span class="Apple-converted-space"> AcceptChanges 涔嬪悗錛屾垨鑷?span class="Apple-converted-space"> DataAdapter.Fill 鍒涘緩浜?jiǎn)琛屼箣鍚庡Q屾湭鍋氬嚭榪囦換浣曟洿鏀廣€?/td>
Added
宸插皢琛屾坊鑷寵〃涓紝浣嗗皻鏈皟鐢?span class="Apple-converted-space"> AcceptChanges銆?/td>
Modified
宸叉洿鏀逛簡(jiǎn)琛岀殑涓€浜涘厓绱犮€?/td>
Deleted
宸插皢璇ヨ浠庤〃涓垹闄わ紝騫朵笖灝氭湭璋冪敤 AcceptChanges銆?/td>
Detached
瀵逛簬宸茬粡鍒涘緩浣嗕笉灞炰簬浠諱綍 DataRowCollection 鐨勮錛岃緗負(fù) Detached銆傛柊寤鴻鐨?span class="Apple-converted-space"> RowState璁劇疆涓?span class="Apple-converted-space"> Detached銆傞€氳繃璋冪敤 Add 鏂規(guī)硶灝嗘柊鐨?span class="Apple-converted-space"> DataRow 娣昏嚦 DataRowCollection 涔嬪悗錛?strong>RowState 灞炴€х殑鍊艱緗負(fù) Added銆?
string custID = custRow["CustomerID", DataRowVersion.Original].ToString();
DataRowVersion
璇存槑
Current
琛岀殑褰撳墠鍊箋€傚鏋滄槸鏈?span class="Apple-converted-space"> Deleted 鐨?span class="Apple-converted-space"> RowState 鐨勮錛屽垯涓嶅瓨鍦ㄦ琛岀増鏈€?/td>
Default
鐗瑰畾琛岀殑榛樿琛岀増鏈€?strong>Added銆?strong>Modified 鎴?span class="Apple-converted-space"> Unchanged 琛岀殑榛樿琛岀増鏈槸Current銆?strong>Deleted 琛岀殑榛樿琛岀増鏈槸 Original銆?strong>Detached 琛岀殑榛樿琛岀増鏈槸 Proposed銆?/td>
Original
琛岀殑鍘熷鍊箋€傚鏋滄槸鏈?span class="Apple-converted-space"> Added 鐨?span class="Apple-converted-space"> RowState 鐨勮錛屽垯涓嶅瓨鍦ㄦ琛岀増鏈€?/td>
Proposed
琛岀殑寤鴻鍊箋€傚湪瀵硅榪涜緙栬緫鎿嶄綔鏈熼棿錛屾垨瀵逛簬涓嶅睘浜?span class="Apple-converted-space"> DataRowCollection 鐨勮錛屽瓨鍦ㄦ琛岀増鏈€?/td>
DataRow[] delRows = catTable.Select(null, null, DataViewRowState.Deleted);
Console.WriteLine("Deleted rows:/n");
foreach (DataColumn catCol in catTable.Columns)
Console.Write(catCol.ColumnName + "/t");
Console.WriteLine();
foreach (DataRow delRow in delRows)
{
foreach (DataColumn catCol in catTable.Columns)
Console.Write(delRow[catCol, DataRowVersion.Original] + "/t");
Console.WriteLine();
}
浠庤〃涓垹闄よ:璇存槑濡備綍浠庤〃涓Щ闄よ銆?/p>
鍦ㄥ皢 DataSet 鎴?span class="Apple-converted-space"> DataTable 涓?span class="Apple-converted-space"> DataAdapter 鍜屽叧緋誨瀷鏁版嵁婧愪竴璧蜂嬌鐢ㄦ椂錛岀敤 DataRow 鐨?span class="Apple-converted-space"> Delete 鏂規(guī)硶縐婚櫎琛屻€?strong>Delete 鏂規(guī)硶鍙槸鍦?span class="Apple-converted-space"> DataSet 鎴?span class="Apple-converted-space"> DataTable 涓皢琛屾爣璁頒負(fù) Deleted錛岃€屼笉浼?xì)绉婚櫎瀹冦€傝€?span class="Apple-converted-space"> DataAdapter 鍦ㄩ亣鍒版爣璁頒負(fù) Deleted 鐨勮鏃訛紝浼?xì)鎵ц鍏?span id="wmqeeuq" class="Apple-converted-space"> DeleteCommand 浠ュ湪鏁版嵁婧愪腑鍒犻櫎璇ヨ銆傜劧鍚庯紝灝卞彲浠ョ敤AcceptChanges 鏂規(guī)硶姘鎬箙縐婚櫎璇ヨ銆傚鏋滀嬌鐢?span class="Apple-converted-space"> Remove 鍒犻櫎璇ヨ錛屽垯璇ヨ灝嗕粠琛ㄤ腑瀹屽叏縐婚櫎錛屼絾DataAdapter 涓嶄細(xì)鍦ㄦ暟鎹簮涓垹闄よ琛屻€?/p>
DataRowCollection 鐨?span class="Apple-converted-space"> Remove 鏂規(guī)硶閲囩敤 DataRow 浣滀負(fù)鍙傛暟錛屽茍灝嗗叾浠庨泦鍚堜腑縐婚櫎錛屽涓嬩緥鎵€紺恒€?/p>
workTable.Rows.Remove(workRow); 浣滀負(fù)瀵規(guī)瘮錛屼互涓嬬ず渚嬫紨紺轟簡(jiǎn)濡備綍璋冪敤 DataRow 涓婄殑 Delete 鏂規(guī)硶鏉ュ皢鍏?span class="Apple-converted-space"> RowState 鏀逛負(fù) Deleted銆?/p>
workRow.Delete(); 濡傛灉灝嗚鏍囪涓哄垹闄わ紝騫朵笖璋冪敤 DataTable 瀵硅薄鐨?span class="Apple-converted-space"> AcceptChanges 鏂規(guī)硶錛岃琛屽氨浼?xì)浠?span id="wmqeeuq" class="Apple-converted-space"> DataTable 涓Щ闄ゃ€傜浉姣斾箣涓嬶紝濡傛灉璋冪敤 RejectChanges錛岃鐨?span class="Apple-converted-space"> RowState 灝變細(xì)鎭㈠鍒拌鏍囪涓?span class="Apple-converted-space"> Deleted 涔嬪墠鐨勭姸鎬併€?/p>
鐢ㄤ簬浠?span class="Apple-converted-space"> DataTable 瀵硅薄涓垹闄?span class="Apple-converted-space"> DataRow 瀵硅薄鐨勬柟娉曟湁涓ょ錛?strong>DataRowCollection 瀵硅薄鐨?span class="Apple-converted-space"> Remove 鏂規(guī)硶鍜?strong>DataRow 瀵硅薄鐨?span class="Apple-converted-space"> Delete 鏂規(guī)硶銆?strong>Remove 鏂規(guī)硶浠?span class="Apple-converted-space"> DataRowCollection 涓垹闄?span class="Apple-converted-space"> DataRow錛岃€?span class="Apple-converted-space"> Delete 鏂規(guī)硶鍙皢琛屾爣璁頒負(fù)鍒犻櫎銆傚綋搴旂敤紼嬪簭璋冪敤 AcceptChanges 鏂規(guī)硶鏃訛紝鎵嶄細(xì)鍙戠敓瀹為檯鐨勫垹闄ゃ€傞€氳繃浣跨敤 Delete錛屾?zhèn)ㄥ彲浠ュ湪瀹為檯鍒犻櫎涔嬪墠鍏堜互缂柦E嬫柟寮忔鏌ュ摢浜涜鏍囪涓哄垹闄ゃ€傚鏋滃皢琛屾爣璁頒負(fù)鍒犻櫎錛屽叾 RowState 灞炴€т細(xì)璁劇疆涓?span class="Apple-converted-space"> Deleted銆?
娉ㄦ剰 濡傛灉 DataRow 鐨?span class="Apple-converted-space"> RowState 鏄?span class="Apple-converted-space"> Added錛屽垯鎰忓懗鐫€宸插皢鍏舵坊鑷寵〃涓紝鐒跺悗灝嗗叾鏍囪涓?strong>Deleted錛屼粠琛ㄤ腑縐婚櫎銆?/blockquote>
娣誨姞鍜岃鍙栬閿欒淇℃伅:璇存槑濡備綍鎸夎鎻掑叆閿欒淇℃伅錛屼互鐢ㄤ簬瑙e喅鏈夊叧搴旂敤紼嬪簭鍐呰涓暟鎹殑闂銆?/p>
DataTable workTable = new DataTable("Customers");
涓轟簡(jiǎn)閬垮厤鍦ㄧ紪杈?span class="Apple-converted-space"> DataTable 涓殑鍊兼椂姣忔鍙戠敓琛岄敊璇兘蹇呴』鍝嶅簲錛屽彲灝嗛敊璇俊鎭坊鑷寵涓紝浠ヤ究浠ュ悗浣跨敤銆?strong>DataRow 瀵硅薄閫氳繃瀵瑰悇琛屾彁渚?span class="Apple-converted-space"> RowError 灞炴€ф潵鏀寔姝ゅ姛鑳姐€傚皢鏁版嵁娣昏嚦 DataRow 鐨?span class="Apple-converted-space"> RowError 灞炴€т細(xì)灝?strong>DataRow 鐨?span class="Apple-converted-space"> HasErrors 灞炴€ф爣璁頒負(fù) true銆傚鏋?span class="Apple-converted-space"> DataRow 鏄?span class="Apple-converted-space"> DataTable 鐨勭粍鎴愰儴鍒嗭紝涓?span class="Apple-converted-space"> DataRow.HasErrors鏄?span class="Apple-converted-space"> true錛屽垯 DataTable.HasErrors 灞炴€т篃鏄?span class="Apple-converted-space"> true銆傝繖涔熼€傜敤浜?span class="Apple-converted-space"> DataTable 鎵€灞炵殑 DataSet銆備負(fù)閿欒鍋氭祴璇曟椂錛屽彲浠ユ鏌?span class="Apple-converted-space"> HasErrors 灞炴€т互紜畾閿欒淇℃伅鏄惁宸叉坊鑷蟲(chóng)墍鏈夎銆傚鏋?span class="Apple-converted-space"> HasErrors 涓?span class="Apple-converted-space"> true錛屽垯鍙嬌鐢?span class="Apple-converted-space"> DataTable 鐨?strong>GetErrors 鏂規(guī)硶浠ヤ究鍙繑鍥炲拰媯€(gè)鏌ユ湁閿欒鐨勮錛屽涓嬩緥鎵€紺恒€?
workTable.Columns.Add("CustID", typeof(Int32));
workTable.Columns.Add("Total", typeof(Double));
workTable.RowChanged += new DataRowChangeEventHandler(OnRowChanged);
for (int i = 0; i < 10; i++)
workTable.Rows.Add(new Object[] {i, i*100});
if (workTable.HasErrors)
{
Console.WriteLine("Errors In Table " + workTable.TableName);
foreach (DataRow myRow in workTable.GetErrors())
{
Console.WriteLine("CustID = " + myRow["CustID"]);
Console.WriteLine(" Error = " + myRow.RowError + "/n");
}
}
protected static void OnRowChanged(Object sender, DataRowChangeEventArgs args)
{
// Check for zero values.
if (args.Row["Total"].Equals(0D))
args.Row.RowError = "Total cannot be 0.";
}
鎺ュ彈鎴栨嫆緇濆琛岀殑鏇存敼:璇存槑濡備綍鎺ュ彈鎴栨嫆緇濆琛岀殑鏇存敼銆?/p>
濡傛灉 DataTable 涓婂瓨鍦ㄥ閿害鏉燂紝浣跨敤 AcceptChanges 鍜?span class="Apple-converted-space"> RejectChanges 鎺ュ彈鎴栨嫆緇濈殑鏇存敼灝變細(xì)鏍規(guī)嵁ForeignKeyConstraint.AcceptRejectRule 浼犳挱鑷?span class="Apple-converted-space"> DataRow 鐨勫瓙琛屻€?/p>
浠ヤ笅紺轟緥媯€(gè)鏌ユ湁閿欒鐨勮錛屽湪閫傜敤涔嬪瑙e喅閿欒錛屾嫆緇濇棤娉曡В鍐抽敊璇殑琛屻€傝娉ㄦ剰錛屽浜庤В鍐崇殑閿欒錛?strong>RowError鍊間細(xì)閲嶇疆涓虹┖瀛楃涓詫紝瀵艱嚧灝?span class="Apple-converted-space"> HasErrors 灞炴€ц緗負(fù) false銆傚綋瑙e喅鎴栨嫆緇濅簡(jiǎn)鎵€鏈夌殑鏈夐敊璇殑琛屾椂錛屽氨浼?xì)璋冪?strong>AcceptChanges 鏉ユ帴鍙楀鏁翠釜 DataTable 鐨勬墍鏈夋洿鏀廣€?/p>
if (workTable.HasErrors)
鍦ㄦ楠岃繃瀵?span class="Apple-converted-space"> DataTable 涓殑鏁版嵁鎵€鍋氭洿鏀圭殑鍑嗙‘鎬т箣鍚庯紝鍙嬌鐢?span class="Apple-converted-space"> DataRow銆?strong>DataTable 鎴?span class="Apple-converted-space"> DataSet 鐨?strong>AcceptChanges 鏂規(guī)硶鏉ユ帴鍙楁洿鏀癸紝姝ゆ柟娉曚細(xì)灝?span class="Apple-converted-space"> Current 琛屽€艱緗負(fù) Original 鍊鹼紝騫朵細(xì)灝?span class="Apple-converted-space"> RowState 灞炴€ц緗負(fù) Unchanged銆傛帴鍙楁垨鎷掔粷鏇存敼浼?xì)娓呴櫎鎵€鏈?span class="Apple-converted-space"> RowError 淇℃伅錛屽茍灝?span class="Apple-converted-space"> HasErrors 灞炴€ц緗負(fù) false銆傛帴鍙楁垨鎷掔粷鏇存敼榪樺彲浠ュ獎(jiǎng)鍝嶅湪鏁版嵁婧愪腑鏇存柊鏁版嵁銆傛湁鍏蟲(chóng)洿澶氫俊鎭紝璇峰弬闃?a style="color: rgb(51,102,153); text-decoration: none" >浣跨敤 DataAdapter 鍜?DataSet 鏇存柊鏁版嵁搴?/a>銆?
{
foreach (DataRow errRow in workTable.GetErrors())
{
if (errRow.RowError == "Total cannot exceed 1000.")
{
errRow["Total"] = 1000;
errRow.RowError = ""; // Clear the error.
}
else
errRow.RejectChanges();
}
}
workTable.AcceptChanges();
澶勭悊 DataTable 浜嬩歡:鎻愪緵鍙敤浜?span class="Apple-converted-space"> DataTable 鐨勪簨浠剁殑鐩稿叧淇℃伅錛屽寘鎷慨鏀瑰垪鍊煎拰娣誨姞鎴栧垹闄よ鏃剁殑浜嬩歡銆?/p>
浠ヤ笅紺轟緥鍒涘緩 4 涓簨浠訛細(xì)OnColumnChanged銆?strong>OnColumnChanging銆?strong>OnRowChanged 鍜?strong>OnRowChanging銆傝繖浜涗簨浠朵腑鐨勬瘡涓€涓兘鍦ㄥ垪鎴栬鏇存敼鏃跺彂鐢熴€?/p>
workTable.ColumnChanged += new DataColumnChangeEventHandler(OnColumnChanged);
DataTable 瀵硅薄鎻愪緵涓€緋誨垪鍙敱搴旂敤紼嬪簭澶勭悊鐨勪簨浠躲€備笅琛ㄨ鏄庝簡(jiǎn) DataTable 浜嬩歡銆?
浜嬩歡
璇存槑
ColumnChanged
鍦ㄥ€煎凡鎴愬姛鎻掑叆鍒楁椂鍙戠敓銆?/td>
ColumnChanging
鍦ㄥ凡鎻愪氦鍒楀€兼椂鍙戠敓銆?/td>
RowChanged
鍦ㄥ凡鎴愬姛緙栬緫琛ㄤ腑鐨勮鍚庡彂鐢熴€?/td>
RowChanging
褰撴鍦ㄦ洿鏀硅〃涓殑琛屾椂鍙戠敓銆?/td>
RowDeleted
鍦ㄨ〃涓殑鏌愯宸茶鏍囪涓?span class="Apple-converted-space"> Deleted 涔嬪悗鍙戠敓銆?/td>
RowDeleting
鍦ㄨ〃涓殑鏌愯琚爣璁頒負(fù) Deleted 涔嬪墠鍙戠敓銆?/td>
workTable.ColumnChanging += new DataColumnChangeEventHandler(OnColumnChanging);
workTable.RowChanged += new DataRowChangeEventHandler(OnRowChanged);
workTable.RowChanging += new DataRowChangeEventHandler(OnRowChanging);
protected static void OnColumnChanged(object sender, DataColumnChangeEventArgs args)
{
Console.Write(" ColumnChanged: ");
Console.Write(args.Column.ColumnName + " changed to '" + args.ProposedValue + "'/n");
}
protected static void OnColumnChanging(object sender, DataColumnChangeEventArgs args)
{
Console.Write("ColumnChanging: ");
Console.Write(args.Column.ColumnName + " equals '" + args.Row[args.Column] +
"', changing to '" + args.ProposedValue + "'/n");
}
protected static void OnRowChanging(object sender, DataRowChangeEventArgs args)
{
if (args.Action != DataRowAction.Nothing)
Console.WriteLine(" RowChanging: Action = " + args.Action + ", CustID = " + args.Row["CustID"]);
}
protected static void OnRowChanged(object sender, DataRowChangeEventArgs args)
{
if (args.Action != DataRowAction.Nothing)
Console.WriteLine(" RowChanged: Action = " + args.Action + ", CustID = " + args.Row["CustID"]);
}
@SQL=SELECT COALESCE(MAX(ColumnName),0)+10 AS DefaultValue FROM TableName WHERE xxParentColumn=@xxParentColumn@
The WHERE part of this clause needs to be replaced with the required values. The code that should appear here is the name of the column which links with the id of the parent one. For example, each record of the C_InvoiceLine belongs to a particular C_Invoice record and they are all sequenced. C_Invoice is the parent table for the lines saved in C_InvoiceLine. This table has a column named line and the default value that it takes is:
@SQL=SELECT COALESCE(MAX(LINE),0)+10 AS DefaultValue FROM C_INVOICELINE WHERE C_INVOICE_ID=@C_INVOICE_ID@
These changes can be done in two different locations:
The first option can be chosen if the original module author wants to add more columns to his/her module. The second option is possible for anyone as the columns are added by a new module to the existing one which is not changed directly.
The main difference between these two methods is the names which need to be chosen for the columns to comply with the modularity naming rules.
In the Application Dictionary || Message window create a new record using the following details:
// create the object through the factory final Category bpg = OBProvider.getInstance().get(Category.class);
Hibernate will detect that a business object is new when:
So if you want to create a new business object with a specific id (by calling setId(...)) then you explicitly need to call businessObject.setNewOBObject(true). Otherwise, Hibernate will throw an exception ('count of batch update operation....').
涓€鏄痩inux鏈嶅姟鍣ㄧ鐨則ftp-server鏀寔,
浜屾槸宓屽叆寮忕洰鏍囩郴緇熺殑tftp-client鏀寔.
鍥犱負(fù)u-boot鏈韓鍐呯疆鏀寔tftp-client,鎵€浠ュ祵鍏ュ紡鐩爣緋葷粺绔氨涓嶇敤閰嶇疆浜?
涓嬮潰灝辮緇嗕粙緇嶄竴涓媗inux鏈嶅姟鍣ㄧtftp server閰嶇疆.鍦╮edhat 9.0鐨勭涓夊紶鍏夌洏?shù)?鏈塼ftp-server鐨勫畨瑁卹pm鍖?錛?錛?nbsp; 瀹夎
#mount –t iso9660 /dev/hdc /mnt/cdrom //鎸傝澆鍏夌洏
#rpm -ivh tftp-server-0.32-4.i386.rpm //瀹夎
#umount /mnt/cdrom //鍗歌澆鍏夌洏
錛?錛変慨鏀規(guī)枃浠跺湪linux涓?涓嶇浣跨敤鐨勬槸鍝竴縐峴uper-server,inetd鎴栬€厁inetd,榛樿鎯呭喌涓婽FTP鏈嶅姟鏄鐢ㄧ殑,鎵€浠ヨ淇敼鏂囦歡鏉ュ紑鍚湇鍔?
鏍規(guī)嵁錛?錛夌殑瀹夎鏂規(guī)硶,鍙互淇敼鏂囦歡/etc/xinetd.d/tftp.涓昏鏄緗甌FTP鏈嶅姟鍣ㄧ殑鏍圭洰褰?寮€鍚湇鍔?
淇敼鍚庣殑鏂囦歡濡備笅:
service tftp {
socket_type =dgram
protocol =udp
wait =yes
user =root
server =/usr/sbin/in.tftpd
server_args =-s /home/app -c
disable =no
per_source =11
cps =100 2
flags =IPv4
}
璇存槑:淇敼欏箂erver_args= -s <path> -c,鍏朵腑<path>澶勫彲浠ユ敼涓轟綘鐨則ftp server閰嶇疆鐨勬牴鐩綍,鍙傛暟-s鎸囧畾chroot,-c鎸囧畾浜?jiǎn)鍙互鍒涘缓鏂囦?
錛?錛夊垱寤簍ftp鏍圭洰褰?鍏抽棴闃茬伀澧?鍚姩tftp-server.
#mkdir /home/app
#chmod o+w /home/app
#/etc/init.d/iptables stop //鍏抽棴闃茬伀澧?/p>
#service xinetd restart //閲嶅惎 xinetd 鏈嶅姟
閲嶅惎xinetd鏈嶅姟,鍥犱負(fù)TFTP鏈嶅姟鍙楁帶涓巟inetd, xinetd鏄鏈嶅姟鐨勬湇鍔?瀹冩槸涓嶅紑绔彛鐨?
楠岃瘉涓€涓婽FTP鏄惁璧鋒潵浜?
# netstat -nlp
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 0.0.0.0:32768 0.0.0.0:* LISTEN 3122/rpc.statd
tcp 0 0 127.0.0.1:32781 0.0.0.0:* LISTEN 4035/xinetd
tcp 0 0 0.0.0.0:111 0.0.0.0:* LISTEN 3103/portmap
tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 3324/httpd
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 3255/sshd
tcp 0 0 127.0.0.1:631 0.0.0.0:* LISTEN 3213/cupsd
tcp 0 0 127.0.0.1:25 0.0.0.0:* LISTEN 3295/sendmail: acce
tcp 0 0 127.0.0.1:6010 0.0.0.0:* LISTEN 3415/0
tcp 0 0 0.0.0.0:443 0.0.0.0:* LISTEN 3324/httpd
udp 0 0 0.0.0.0:32768 0.0.0.0:* 3122/rpc.statd
udp 0 0 0.0.0.0:69 0.0.0.0:* 4035/xinetd ;
鍙互鐪嬪埌69绔彛宸茬粡鎵撳紑
udp 0 0 0.0.0.0:69 0.0.0.0:* 4012/in.tftpd
udp 0 0 0.0.0.0:111 0.0.0.0:* 3103/portmap
udp 0 0 0.0.0.0:754 0.0.0.0:* 3122/rpc.statd
udp 0 0 0.0.0.0:631 0.0.0.0:* 3213/cupsd
榪欐牱,tftp server閰嶇疆鐨勫惎鍔ㄦ楠ゅ氨瀹屾垚浜?jiǎn)銆?/p>
浣犲彲浠ョ櫥闄嗘湰鏈烘祴璇曚互涓?鍛戒護(hù)濡備笅:
#tftp your-ip-address
tftp>get <download file>
tftp>put <upload file>
tftp>q
鍥?銆佸嚑鐐硅璁頒綇錛?/p>
銆€銆€1 浣跨敤#using寮曠敤C# DLL錛岃€屼笉鏄?include.鎴戝氨鏄兂褰撶劧鐨勪嬌鐢ㄤ簡(jiǎn)鍚庤€咃紝鎵€浠ユ氮璐逛簡(jiǎn)涓€涓婂崍鐨勬椂闂達(dá)紱
銆€銆€2 鍒繕?shù)簡(jiǎn)using namespace CSLib錛?/p>
銆€銆€3 浣跨敤C++/clr璇硶錛岄噰鐢ㄦ紜殑璁塊棶鎵樼瀵硅薄錛屽嵆錛氫嬌鐢ㄥ附瀛?#8216;^’錛岃€屼笉鏄槦鏄?#8216;*’銆?br />
PS錛氶檮涓婅嚜宸辨垚鍔熻繍琛孋++浠g爜
#include "stdafx.h"
#include <iostream>
//#using "..\..\SFCSDLL.dll" //鍙沖嚮欏圭洰-->寮曠敤...錛屾坊鍔犳柊寮曠敤錛屽皢DLL娣誨姞鍒伴」鐩腑錛屽彲浠ヤ笉鐢ㄦ琛屼唬鐮?/p>
using namespace std;
using namespace SFCSDLL;
int _tmain(int argc, _TCHAR* argv[])
{
Class1 ^c = gcnew Class1();
c->SFCSDLL_Create_Connection("127.0.0.1", 0, 0, 0, 0);
c->SFCSDLL_Get_DLLVersion();
c->SFCSDLL_Close_Connection();
cout<<"end...";
system("pause");
return 0;
}
鍦╒S2008閲岋紝涔熷彲浠ュ儚Eclipse閭f牱鑷姩鐢熸垚get 銆乻et鏂規(guī)硶銆?br />
涓嬮潰鏄袱涓叿浣撴搷浣滅殑鏂規(guī)硶錛?br />
1銆佸湪緙栧啓鐨勫瓧孌典笂鍗曞嚮鍙抽敭----->閲嶆瀯------->灝佽瀛楁
2銆佸湪絀虹櫧琛屽錛岃緭鍏?#8220;prop”鍐嶆寜Tab閿?/p>