freepeople性欧美熟妇, 色戒完整版无删减158分钟hd, 无码精品国产vα在线观看DVD, 丰满少妇伦精品无码专区在线观看,艾栗栗与纹身男宾馆3p50分钟,国产AV片在线观看,黑人与美女高潮,18岁女RAPPERDISSSUBS,国产手机在机看影片

正文內(nèi)容

數(shù)據(jù)適配器-sqldataadapter類-資料下載頁(yè)

2025-07-19 17:55本頁(yè)面
  

【正文】 wUpdating 和 RowUpdated ? 可以使用 Status 屬性來(lái)確定該操作過(guò)程中是否出錯(cuò),如果需要,還可以控制對(duì)當(dāng)前和結(jié)果行執(zhí)行的操作。當(dāng)該事件發(fā)生時(shí), Status 屬性將等于 Continue 或 ErrorsOccurred。 ? 下表顯示為了控制更新過(guò)程中的后繼操作,可以將 Status 屬性設(shè)置為的值。 Continue 繼續(xù)執(zhí)行更新操作。 ErrorsOccurred 中止更新操作并引發(fā)異常。 SkipCurrentRow 忽略當(dāng)前行并繼續(xù)執(zhí)行更新操作。 SkipAllRemainingRows 中止更新操作但不引發(fā)異常。 ? 如果將 Status 屬性設(shè)置為 ErrorsOccurred,則將引發(fā)異常。您可以通過(guò)將 Errors 屬性設(shè)置為預(yù)期異常來(lái)控制所引發(fā)的異常。如果使用其他 Status 值之一,則將防止引發(fā)異常。 ? 也可以使用 ContinueUpdateOnError 屬性為已更新的行處理錯(cuò)誤。如果 為 true,那么當(dāng)對(duì)行結(jié)果的更新導(dǎo)致異常時(shí),該異常的文本將被放入特定行的 RowError 信息中,并且處理將會(huì)繼續(xù)而不會(huì)引發(fā)異常。這樣,當(dāng) Update 完成時(shí),就可以對(duì)錯(cuò)誤作出響應(yīng),而不是對(duì) RowUpdated 事件作出響應(yīng),這使得能夠在遇到錯(cuò)誤時(shí)響應(yīng)錯(cuò)誤。 RowUpdating 和 RowUpdated ? 當(dāng)使用 Update時(shí),每一個(gè)更新的數(shù)據(jù)行都會(huì)發(fā)生兩個(gè)事件。執(zhí)行順序如下: 1. 將 DataRow中的值移至參數(shù)值。 2. 引發(fā) OnRowUpdating事件。 3. 執(zhí)行命令。 4. 如果該命令設(shè)置為 FirstReturnedRecord,則第一個(gè)返回結(jié)果放在 DataRow中。 5. 如果存在輸出參數(shù),它們將被放在 DataRow中。 6. 引發(fā) OnRowUpdated事件。 7. 調(diào)用 AcceptChanges。 例 1:以下代碼示例顯示如何添加和移除事件處理程序。 RowUpdating 事件處理程序編寫(xiě)所有已刪除記錄的日志,該日志帶有一個(gè)時(shí)間戳。 RowUpdated 事件處理程序?qū)㈠e(cuò)誤信息添加到 DataSet 中行的 RowError 屬性,取消異常,并繼續(xù)處理(靜像 ContinueUpdateOnError = true 的行為)。 SqlDataAdapter custDA = new SqlDataAdapter(SELECT CustomerID, CompanyName FROM Customers, nwindConn)。 // Add handlers. += new SqlRowUpdatingEventHandler(OnRowUpdating)。 += new SqlRowUpdatedEventHandler(OnRowUpdated)。 // Set DataAdapter mand properties, fill the DataSet, and modify the DataSet. (custDS, Customers)。 // Remove handlers. = new SqlRowUpdatingEventHandler(OnRowUpdating)。 = new SqlRowUpdatedEventHandler(OnRowUpdated)。 protected static void OnRowUpdating(object sender, SqlRowUpdatingEventArgs args) { if ( == ) { tw = ()。 ({0}: Customer {1} Deleted., , [CustomerID, ])。 ()。 } } protected static void OnRowUpdated(object sender, SqlRowUpdatedEventArgs args) { if ( == ) { = 。 = 。 } } 例 2 // handler for RowUpdating event protected static void OnRowUpdating(object sender, SqlRowUpdatingEventArgs e) { PrintEventArgs(e)。 } // handler for RowUpdated event protected static void OnRowUpdated(object sender, SqlRowUpdatedEventArgs e) { PrintEventArgs(e)。 } public static int Main(String[] args) { const string CONNECTION_STRING = Persist Security Info=False。Integrated Security=SSPI。database=northwind。server=(local)。 const string SELECT_ALL = select * from Products。 // create DataAdapter SqlDataAdapter rAdapter = new SqlDataAdapter(SELECT_ALL, CONNECTION_STRING)。 SqlCommandBuilder cb = new SqlCommandBuilder(rAdapter)。 // Create and fill dataset (select only first 5 rows) DataSet rDataSet = new DataSet()。 (rDataSet, 0, 5, Table)。 // Modify dataSet DataTable rTable = [Table]。 [0][1] = new product。 // add handlers += new SqlRowUpdatingEventHandler( OnRowUpdating )。 += new SqlRowUpdatedEventHandler( OnRowUpdated )。 // update, this operation fires two events (RowUpdating/RowUpdated) per changed row (rDataSet, Table)。 // remove handlers = new SqlRowUpdatingEventHandler( OnRowUpdating )。 = new SqlRowUpdatedEventHandler( OnRowUpdated )。 return 0。 } protected static void OnRowUpdating(object sender, SqlRowUpdatingEventArgs args) { (OnRowUpdating)。 ( event args: (+ mand= + + mandType= + + status= + + ))。 } protected static void OnRowUpdated(object sender, SqlRowUpdatedEventArgs args) { (OnRowUpdated)。 ( event args: (+ mand= + + mandType= + + recordsAffected= + + status= + + ) )。 } FillError ? 當(dāng) Fill 操作過(guò)程中出錯(cuò)時(shí), DataAdapter 將發(fā)出 FillError 事件。當(dāng)所添加行中的數(shù)據(jù)必須損失一些精度才能轉(zhuǎn)換成 .NET Framework 類型時(shí),通常會(huì)發(fā)生這種類型的錯(cuò)誤。 ? 如果在 Fill 操作過(guò)程中出錯(cuò),則當(dāng)前行將不會(huì)被添加到 DataTable 中。FillError 事件使您能夠解決錯(cuò)誤并添加當(dāng)前行,或者忽略已排除的行并繼續(xù)執(zhí)行 Fill 操作。 ? 向 FillError 事件傳遞的 FillErrorEventArgs 可以包含幾項(xiàng)可用于響應(yīng)和解決錯(cuò)誤的屬性。下表顯示了 FillErrorEventArgs 對(duì)象的屬性。 屬性 說(shuō)明 Errors 已發(fā)生的 Exception。 DataTable 出錯(cuò)時(shí)所填充的 DataTable 對(duì)象。 Values 一個(gè)對(duì)象數(shù)組,它包含出錯(cuò)時(shí)所添加的行的值。 Values 數(shù)組的序號(hào)引用對(duì)應(yīng)于所添加的行的列的序號(hào)引用。例如, Values[0] 是作為當(dāng)前行的第一列添加的值。 Continue 用于選擇是否引發(fā) Exception。如果將 Continue 屬性設(shè)置為 false,則將中止當(dāng)前 Fill 操作并引發(fā)異常。如果將 Continue 設(shè)置為 true,那么即使出錯(cuò),仍將繼續(xù)執(zhí)行 Fill 操作。 ? 以下代碼示例為 DataAdapter 的 FillError 事件添加一個(gè)事件處理程序。在 FillError 事件代碼中,該示例確定是否可能出現(xiàn)精度損失,并提供響應(yīng)該異常的機(jī)會(huì) += new FillErrorEventHandler(FillError)。 DataSet myDS = new DataSet()。 (myDS, MyTable)。 protected static void FillError(object sender, FillErrorEventArgs args) { if (() == typeof()) { // Code to handle precision loss. //Add a row to table using the values from the first two columns. DataRow myRow = (new object[] {[0], [1], })。 //Set the RowError containing the value for the third column. = OverflowException Encountered. Value from data source: + [2]。 = true。 }
點(diǎn)擊復(fù)制文檔內(nèi)容
教學(xué)教案相關(guān)推薦
文庫(kù)吧 www.dybbs8.com
備案圖鄂ICP備17016276號(hào)-1