免费视频淫片aa毛片_日韩高清在线亚洲专区vr_日韩大片免费观看视频播放_亚洲欧美国产精品完整版

打開APP
userphoto
未登錄

開通VIP,暢享免費(fèi)電子書等14項(xiàng)超值服

開通VIP
DbDataAdapter.Update 方法 (DataSet, String) (System.Data.Common)

Update method, the DbDataAdapter examines the RowState property, and executes the required INSERT, UPDATE, or DELETE statements iteratively for each row, based on the order of the indexes configured in the DataSet." xml:space="preserve">當(dāng)應(yīng)用程式呼叫 Update 方法時(shí),DbDataAdapter 會根據(jù) DataSet 中設(shè)定的索引順序檢查 RowState 屬性,並反覆的為每個(gè)資料列執(zhí)行必要的 INSERT、UPDATE 或 DELETE 陳述式。 Update might execute a DELETE statement, followed by an INSERT statement, and then another DELETE statement, due to the ordering of the rows in the DataTable." xml:space="preserve">例如,Update 可能會因?yàn)?DataTable 中資料列的順序,而先執(zhí)行 DELETE 陳述式,然後 INSERT 陳述式,最後再執(zhí)行另一個(gè) DELETE 陳述式。

應(yīng)該注意的是,這些陳述式並不會當(dāng)做一個(gè)批次程序來執(zhí)行,而是每個(gè)資料列個(gè)別更新。 GetChanges method in situations where you must control the sequence of statement types (for example, INSERT before UPDATE)." xml:space="preserve">應(yīng)用程式可以在必須控制陳述式類型順序 (例如 INSERT 在 UPDATE 之前) 的情況下,呼叫 GetChanges 方法。 Updating the Database With a DataAdapter and a DataSet." xml:space="preserve">如需詳細(xì)資訊,請參閱以 DataAdapter 更新資料來源。

Update method generates an exception." xml:space="preserve">如果尚未指定 INSERT、UPDATE 或 DELETE 陳述式,則 Update 方法會產(chǎn)生例外狀況。 SqlCommandBuilder or OleDbCommandBuilder object to automatically generate SQL statements for single-table updates if you set the SelectCommand property of a .NET Framework data provider." xml:space="preserve">然而,如果您設(shè)定 .NET Framework 資料提供者的 SelectCommand 屬性,即可建立 SqlCommandBuilderOleDbCommandBuilder 物件,自動產(chǎn)生單一資料表更新的 SQL 陳述式。 接著,CommandBuilder 會產(chǎn)生您尚未設(shè)定的其他任何 SQL 陳述式。 DataSet." xml:space="preserve">這個(gè)產(chǎn)生邏輯需要索引鍵資料行資訊以存在於 DataSet 中。 Automatically Generated Commands." xml:space="preserve">如需詳細(xì)資訊,請參閱使用 CommandBuilders 產(chǎn)生命令

Update method supports scenarios where the DataSet contains multiple DataTable objects whose names differ only by case." xml:space="preserve"> Update 方法支援 DataSet 包含多個(gè)只有名稱大小寫不同的 DataTable 物件的案例。 DataSet, Update performs a case-sensitive comparison to find the corresponding table, and generates an exception if no exact match exists." xml:space="preserve">當(dāng) DataSet 中存在多個(gè)具有相同名稱,但名稱大小寫不同的資料表時(shí),Update 會執(zhí)行區(qū)分大小寫的比較以尋找對應(yīng)的資料表,如果找不到相符的資料表,則會產(chǎn)生例外狀況。 下列 C# 程式碼會說明這個(gè)行為。

DataSet ds = new DataSet(); ds.Tables.Add("aaa"); ds.Tables.Add("AAA"); adapter.Update(ds, "aaa"); // Updates "aaa", which already exists in the DataSet. adapter.Update(ds, "AAA"); // Updates "AAA", which already exists in the DataSet.    adapter.Update(ds, "Aaa"); // Results in an exception.

Update is called and the DataSet contains only one DataTable whose name differs only by case, that DataTable is updated." xml:space="preserve">如果呼叫 Update,並且 DataSet 只包含一個(gè)只有名稱大小寫不同的 DataTable,則會更新該 DataTable。 在這個(gè)案例中,比較是不區(qū)分大小寫的。 下列 C# 程式碼會說明這個(gè)行為。

DataSet dataset = new DataSet(); dataset.Tables.Add("aaa");    adapter.Update(dataset, "AAA"); // Updates table "aaa" because only one similarly named table is in the DataSet.

Update method retrieves rows from the table listed in the first mapping before performing an update." xml:space="preserve"> Update 方法會在執(zhí)行更新之前,從第一次對應(yīng)所列的資料表中擷取資料列。 Update then refreshes the row using the value of the UpdatedRowSource property." xml:space="preserve">然後 Update 會使用 UpdatedRowSource 屬性的值重新整理資料列。 其他的所有資料列會被忽略。

DataSet, the OnRowUpdated event is raised, allowing the user to inspect the reconciled DataSet row and any output parameters returned by the command." xml:space="preserve">在任何資料載入回 DataSet 後,會引發(fā) OnRowUpdated 事件,允許使用者檢查調(diào)整的 DataSet 資料列以及命令所傳回的任何輸出參數(shù)。 更新資料列成功後,對該資料列的變更將被接受。

Update, the order of execution is as follows: " xml:space="preserve">使用 Update 時(shí),執(zhí)行的順序如下:

  1. DataRow are moved to the parameter values." xml:space="preserve"> DataRow 中的值會移動至參數(shù)值。

  2. OnRowUpdating event is raised." xml:space="preserve">便會引發(fā) OnRowUpdating 事件。

  3. 執(zhí)行命令。

  4. FirstReturnedRecord, then the first returned result is placed in the DataRow." xml:space="preserve">如果命令設(shè)定為 FirstReturnedRecord,則傳回的第一個(gè)結(jié)果會放置在 DataRow 中。

  5. DataRow." xml:space="preserve">如果有輸出參數(shù),它們會被放置於 DataRow

  6. OnRowUpdated event is raised." xml:space="preserve">便會引發(fā) OnRowUpdated 事件。

  7. AcceptChanges is called." xml:space="preserve">呼叫 AcceptChanges。

DbDataAdapter usually has a parameters collection associated with it." xml:space="preserve">DbDataAdapter 關(guān)聯(lián)的每個(gè)命令通常都具有與它關(guān)聯(lián)的參數(shù)集合。 SourceColumn and SourceVersion properties of a .NET Framework data provider's Parameter class." xml:space="preserve">會經(jīng)由 .NET 資料提供者之 Parameter 類別的 SourceColumnSourceVersion 屬性,將參數(shù)對應(yīng)至目前的資料列。 SourceColumn refers to a DataTable column that the DbDataAdapter references to obtain parameter values for the current row." xml:space="preserve"> SourceColumn 會參考 DataTable 資料行,DbDataAdapter 參考該資料行以取得目前資料列的參數(shù)值。

SourceColumn refers to the unmapped column name before any table mappings have been applied." xml:space="preserve">在套用任何資料表對應(yīng)之前,SourceColumn 會參考未對應(yīng)的資料行名稱。 SourceColumn refers to a nonexistent column, the action taken depends on one of the following MissingMappingAction values." xml:space="preserve">如果 SourceColumn 參考不存在的資料行,則會根據(jù)下列其中一個(gè) MissingMappingAction 值來採取動作。

列舉型別值

採取的動作

MissingMappingAction.Passthrough

DataSet if no mapping is present. " xml:space="preserve">如果沒有對應(yīng)存在,會使用 DataSet 中的來源資料行名稱和資料表名稱。

MissingMappingAction.Ignore

SystemException is generated." xml:space="preserve">產(chǎn)生 SystemException 當(dāng)明確設(shè)定對應(yīng)時(shí),輸入?yún)?shù)的對應(yīng)遺漏通常是錯(cuò)誤的結(jié)果。

MissingMappingAction.Error

SystemException is generated. " xml:space="preserve">產(chǎn)生 SystemException

SourceColumn property is also used to map the value for output or input/output parameters back to the DataSet." xml:space="preserve"> SourceColumn 屬性也用來將輸出或輸入/輸出參數(shù)的值對應(yīng)回 DataSet。 如果參考不存在的資料行,會產(chǎn)生例外狀況。

SourceVersion property of a .NET Framework data provider's Parameter class determines whether to use the Original, Current, or Proposed version of the column value." xml:space="preserve">.NET Framework 資料提供者之 Parameter 類別的 SourceVersion 屬性會判斷要使用資料行值的 Original、Current 或 Proposed 版本。 這個(gè)功能常用來包含 UPDATE 陳述式的 WHERE 子句中的原始值,以檢查開放式並行存取違規(guī)。

注意事項(xiàng)

如果更新資料列時(shí)發(fā)生錯(cuò)誤,便會擲回例外狀況並且中斷執(zhí)行更新。 ContinueUpdateOnError property to true before calling Update." xml:space="preserve">若要在遇到錯(cuò)誤時(shí)繼續(xù)更新作業(yè),而不產(chǎn)生例外狀況,請?jiān)诤艚?Update 前設(shè)將 ContinueUpdateOnError 屬性設(shè)為 true。 RowUpdated event of a DataAdapter." xml:space="preserve">您也可以在 DataAdapter 的 RowUpdated 事件中以每個(gè)資料列為基礎(chǔ)來回應(yīng)錯(cuò)誤。 RowUpdated event, set the Status property of the RowUpdatedEventArgs to Continue." xml:space="preserve">若要在 RowUpdated 事件中繼續(xù)更新作業(yè),而不產(chǎn)生例外狀況,請將 RowUpdatedEventArgsStatus 屬性設(shè)為 Continue。

public DataSet CreateCmdsAndUpdate(string connectionString, string queryString, string tableName) { using (OleDbConnection connection = new OleDbConnection(connectionString)) { OleDbDataAdapter adapter = new OleDbDataAdapter(); adapter.SelectCommand = new OleDbCommand(queryString, connection); OleDbCommandBuilder builder = new OleDbCommandBuilder(adapter); connection.Open(); DataSet customers = new DataSet(); adapter.Fill(customers); //code to modify data in dataset here adapter.Update(customers, tableName); return customers; }}
本站僅提供存儲服務(wù),所有內(nèi)容均由用戶發(fā)布,如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,請點(diǎn)擊舉報(bào)
打開APP,閱讀全文并永久保存 查看更多類似文章
猜你喜歡
類似文章
XmlImplementation 類 (System.Xml)
CSocket::FromHandle
使用非托管 DLL 函數(shù)
PrinterResolution.X 屬性 (System.Drawing.Printing)
更改 ClickOnce 應(yīng)用程序的發(fā)布語言
C# 如何:確定安裝了哪些 .NET Framework 版本
更多類似文章 >>
生活服務(wù)
分享 收藏 導(dǎo)長圖 關(guān)注 下載文章
綁定賬號成功
后續(xù)可登錄賬號暢享VIP特權(quán)!
如果VIP功能使用有故障,
可點(diǎn)擊這里聯(lián)系客服!

聯(lián)系客服