<?xml version="1.0" encoding="UTF-8"?> <rss
version="2.0"
xmlns:content="http://purl.org/rss/1.0/modules/content/"
xmlns:wfw="http://wellformedweb.org/CommentAPI/"
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:atom="http://www.w3.org/2005/Atom"
xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
><channel><title>mr.mu &#187; .Net Framework</title> <atom:link href="http://www.mrmu.com.tw/category/otherprogramming/dotnet/feed/" rel="self" type="application/rss+xml" /><link>http://www.mrmu.com.tw</link> <description>WordPress 網站架設、軟體設計、互動介面研究</description> <lastBuildDate>Wed, 08 Feb 2012 08:24:17 +0000</lastBuildDate> <language>en</language> <sy:updatePeriod>hourly</sy:updatePeriod> <sy:updateFrequency>1</sy:updateFrequency> <generator>http://wordpress.org/?v=3.1.2</generator> <item><title>BindingSource物件</title><link>http://www.mrmu.com.tw/2008/08/15/bindingsource%e7%89%a9%e4%bb%b6/</link> <comments>http://www.mrmu.com.tw/2008/08/15/bindingsource%e7%89%a9%e4%bb%b6/#comments</comments> <pubDate>Fri, 15 Aug 2008 03:19:00 +0000</pubDate> <dc:creator>mrmu</dc:creator> <category><![CDATA[.Net Framework]]></category> <category><![CDATA[.net framework]]></category><guid
isPermaLink="false">http://www.mrmu.com.tw/2008/08/15/bindingsource%e7%89%a9%e4%bb%b6/</guid> <description><![CDATA[BindingSource 元件有兩個用途。第一，它會在表單上的控制項繫結至資料時，提供間接取值 (Indirection) 層。這項作業的完成，是透過將 BindingSource 元件繫結至資料來源，然後將表單上的控制項繫結至 BindingSource 元件。所有與資料的進一步互動 (包括巡覽、排序、篩選和更新) 都會透過呼叫 BindingSource 元件來完成。 雖然 BindingNavigator 控制項是特別設計用來與 BindingSource 元件搭配使用的，不過還是可以使用 BindingSource 元件將任何 Windows Form 控制項繫結至資料來源，如ComboBox跟DataGridView，繫結至某資料表的BindingSource後，其內容就會是該資料表的記錄。DataGridView元件的欄位(Cell)，也可以表示為控制項(如ComboBoxCell, TextBoxCell等)，這些控制項也可以使用DataSource成員來做Binding。 根據預設，BindingNavigator 控制項所提供的按鈕是對應到 BindingSource 元件上的巡覽方法。 跟TableAdapter一樣，透過精靈操作時，若我們直接將資料表拉入表單(Form)，它會自動加入元件至表單，並做好Binding動作(每個資料表都會有一個BindingSource物件)，不管是使用「詳細資料」或「DataGridView」的方式皆會產生BindingSource物件。 BindingSource的類別成員 (msdn)]]></description> <wfw:commentRss>http://www.mrmu.com.tw/2008/08/15/bindingsource%e7%89%a9%e4%bb%b6/feed/</wfw:commentRss> <slash:comments>0</slash:comments> </item> <item><title>TableAdapter</title><link>http://www.mrmu.com.tw/2008/08/01/tableadapter/</link> <comments>http://www.mrmu.com.tw/2008/08/01/tableadapter/#comments</comments> <pubDate>Fri, 01 Aug 2008 12:36:00 +0000</pubDate> <dc:creator>mrmu</dc:creator> <category><![CDATA[.Net Framework]]></category> <category><![CDATA[.net framework]]></category><guid
isPermaLink="false">http://www.mrmu.com.tw/2008/08/01/tableadapter/</guid> <description><![CDATA[TableAdapter 提供應用程式與資料庫之間的通訊。TableAdapter 會連接到資料庫、執行查詢或預存程序，然後傳回一個已填入傳回之資料的新資料表，或是將傳回之資料填入現有的 DataTable (DataSet裝著一堆DataTable)。TableAdapter 也可用來將應用程式中更新的資料傳回到資料庫。 透過精靈的操作，vb.net會自動做一些事，大概是這樣的： 1. 新增資料來源 &#8594; 自動建立DataSet，它含有部份原始DB其中一部份的資料表(看你選了哪些資料表進來)&#160; 2.&#160;當我們將資料表拉入表單(Form)時 &#8594; 不管是用「詳細資料」的方式還是DataGridView，vb.net都會自動為該資料表做一個TableAdapter (一般會在Form_Load先幫你作Fill的預設動作，把全部資料查詢出來)，除了生出TableAdapter，還會建立對應控制項的BindingSource物件。]]></description> <wfw:commentRss>http://www.mrmu.com.tw/2008/08/01/tableadapter/feed/</wfw:commentRss> <slash:comments>0</slash:comments> </item> <item><title>並行違規</title><link>http://www.mrmu.com.tw/2008/07/13/%e4%b8%a6%e8%a1%8c%e9%81%95%e8%a6%8f/</link> <comments>http://www.mrmu.com.tw/2008/07/13/%e4%b8%a6%e8%a1%8c%e9%81%95%e8%a6%8f/#comments</comments> <pubDate>Sun, 13 Jul 2008 12:10:00 +0000</pubDate> <dc:creator>mrmu</dc:creator> <category><![CDATA[.Net Framework]]></category> <category><![CDATA[.net framework]]></category><guid
isPermaLink="false">http://www.mrmu.com.tw/2008/07/13/%e4%b8%a6%e8%a1%8c%e9%81%95%e8%a6%8f/</guid> <description><![CDATA[接續上篇的練習，在新增一筆記錄後按"更新"按鈕，記錄的確會被寫回資料庫，但隨即刪除這筆記錄後再按"更新"，另一個錯誤就可能出現了：對於初次見到這個訊息的我而言，我只能感覺到設計這行字的工程師真是天才，試問誰能一眼就了解這是錯在哪呢&#8230; 並行違規的問題似乎是因為第一個存取記錄的人把資料取回應用程式後，在要寫回資料庫時，由於第二個人已改變記錄了，因此造成二個以上的人同時編輯記錄，結果產生並行違規。在這個範例中，第二個人就是你自己。 簡單的解決方式是針對此情況對使用者發出提示，可以使用DBConcurrencyException來得知並行違規的問題發生了(處理並行存取錯誤的說明)，確定要寫入就再做一次Fill及AcceptChanges()，不過最適當的方式還是要視專案情況(不同的商業邏輯)來解決：Private Sub BtnUpdate_Click(ByVal sender As System.Object,_ ByVal e As System.EventArgs)_ Handles BtnUpdate.Click If NORTHWNDDataSet.HasChanges Then Dim dsChanged As DataSet dsChanged = NORTHWNDDataSet.GetChanges(DataRowState.Added +_ DataRowState.Deleted +_ DataRowState.Modified) Try ProductsTableAdapter.Update(dsChanged) NORTHWNDDataSet.AcceptChanges() Catch ex As Data.DBConcurrencyException &#8216;處理並行違規的例外 If MessageBox.Show("資料變更過，仍要更新嗎？", _ "錯誤", _ MessageBoxButtons.YesNo) = _ Windows.Forms.DialogResult.Yes Then Me.ProductsTableAdapter.Fill(Me.NORTHWNDDataSet.Products) NORTHWNDDataSet.AcceptChanges() End If Catch ex As Exception MessageBox.Show(ex.Message) [...]]]></description> <wfw:commentRss>http://www.mrmu.com.tw/2008/07/13/%e4%b8%a6%e8%a1%8c%e9%81%95%e8%a6%8f/feed/</wfw:commentRss> <slash:comments>0</slash:comments> </item> <item><title>The DELETE statement conflicted with the REFERENCE constraint</title><link>http://www.mrmu.com.tw/2008/07/12/the-delete-statement-conflicted-with-the-reference-constraint/</link> <comments>http://www.mrmu.com.tw/2008/07/12/the-delete-statement-conflicted-with-the-reference-constraint/#comments</comments> <pubDate>Sat, 12 Jul 2008 06:11:00 +0000</pubDate> <dc:creator>mrmu</dc:creator> <category><![CDATA[.Net Framework]]></category> <category><![CDATA[.net framework]]></category><guid
isPermaLink="false">http://www.mrmu.com.tw/2008/07/12/the-delete-statement-conflicted-with-the-reference-constraint/</guid> <description><![CDATA[這是在練習VB.net更新DataSet時遇到的第一個錯誤訊息。 練習更新DataSet時，做出了一個如下圖這樣的表單(一個label, 一個comboBox, 一個button, 兩個DataGridView)： 以NORTHWIND範例資料庫為例，新增Products, Suppliers, Order Details資料表作為資料來源(如右圖)。 Products資料表階層下之所以還有個Order Details的資料表，主要是因為兩者之間有關聯(以ProductsID作關聯)，Products為父資料表，Order Details為子資料表。同樣的，Suppliers與Products之間也有如此關聯(以SupplierID作關聯)。三個資料表之間的關聯如下圖。 這個簡單的例子要讓User能直接對DataGridView進行新增、刪除、修改後，在表單上提供一個"更新"按鈕讓User完成修改後可以將記錄寫回至資料庫。在放好Label, comboBox (DataSource屬性設為Suppliers資料表, DislayMember為Company Name，ValueMember為SupplierID)後，接著直接將資料來源視窗內的Suppliers資料表階層下的Products資料表拉進表單，成為表單中間的DataGridView；同樣的，Products下面的Order Details拉進，為下面的DataGridView。 更新按鈕的Click事件函數如下(為求簡單，先不考慮異常例外的處理)： 執行的畫面如下： 此時刪除Products記錄，可能會出現如下錯誤訊息： 這樣看來是容易理解的，因為NORTHWIND在Products與Order Details資料表存在Foreign Key(外來鍵)，若刪除某個Product，該ID必須沒有與其他資料表有關聯，否則此關聯就被破壞了。例如，若把ID為38的產品刪除了，那所有訂單中有訂購ID為38的產品都將關聯不到ID為38的產品。解決方法可能就必須先刪除Order Details所有有訂購ID為38的產品之記錄，不過完整正確的作法當然要提示User，也要對有訂38的訂單記錄作適當的處理。]]></description> <wfw:commentRss>http://www.mrmu.com.tw/2008/07/12/the-delete-statement-conflicted-with-the-reference-constraint/feed/</wfw:commentRss> <slash:comments>0</slash:comments> </item> </channel> </rss>
<!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/

Minified using disk
Page Caching using disk (enhanced)
Database Caching 1/27 queries in 0.065 seconds using disk
Object Caching 403/443 objects using disk

Served from: www.mrmu.com.tw @ 2012-02-12 07:07:57 -->
