Click here to Skip to main content
16,006,749 members
Home / Discussions / C#
   

C#

 
GeneralRe: launch & run cmd.exe Pin
Tom Archer24-Jul-03 5:28
Tom Archer24-Jul-03 5:28 
GeneralRe: launch & run cmd.exe Pin
Tom Archer24-Jul-03 5:31
Tom Archer24-Jul-03 5:31 
GeneralRe: launch & run cmd.exe Pin
nam2324-Jul-03 6:19
nam2324-Jul-03 6:19 
QuestionHow to swap primary key values in a DataTable? Pin
Radoslav Bielik24-Jul-03 4:35
Radoslav Bielik24-Jul-03 4:35 
AnswerRe: How to swap primary key values in a DataTable? Pin
Tom Archer24-Jul-03 7:21
Tom Archer24-Jul-03 7:21 
GeneralRe: How to swap primary key values in a DataTable? Pin
Radoslav Bielik24-Jul-03 7:33
Radoslav Bielik24-Jul-03 7:33 
GeneralRe: How to swap primary key values in a DataTable? Pin
Tom Archer24-Jul-03 7:37
Tom Archer24-Jul-03 7:37 
GeneralRe: How to swap primary key values in a DataTable? Pin
Tom Archer5-Aug-03 12:39
Tom Archer5-Aug-03 12:39 
(Repeated from our private email so that others searching for this answer will find it.)

Hi Rado,

Ever have one of those problem that just eats at you? Well your situation has bugged me for some time because I just knew there had to be an easier, more elegant way. There is......

The problem was that BeginEdit calls for the two DataRow objects were disabling the constraints for the respective rows, but once you called EndEdit for one DataRow, the primary key value for that first row conflicted with the (not yet committed) second DataRow object. Therefore, I had to assume that there was a higher level way of turning off constraints - either the DataRowCollection or the DataTable. Finally, I found the DataTable::BeginLoadData and DataTable::EndLoadData method, which turn off and on, respectively, constraint checking and index maintenance for the entire table.

<br />
table.BeginLoadData();<br />
<font color=green>// switch the primary keys for your two DataRow objects</font><br />
table.EndLoadData();<br />


Note: You mentioned the fact that someone suggested turning constraints off for the entire DataSet. As this technicall will work, using BeginLoadData and EndLoadData will affect only one table instead of all the tables for a given DataSet.


Cheers,
Tom Archer
Inside C#,
Extending MFC Applications with the .NET Framework
It's better to listen to others than to speak, because I already know what I'm going to say anyway. - friend of Jörgen Sigvardsson
AnswerRe: How to swap primary key values in a DataTable? Pin
StealthyMark26-Jul-03 14:50
StealthyMark26-Jul-03 14:50 
GeneralRe: How to swap primary key values in a DataTable? Pin
Radoslav Bielik27-Jul-03 11:49
Radoslav Bielik27-Jul-03 11:49 
GeneralGeneric / Text Only print Pin
MadsJ24-Jul-03 3:13
MadsJ24-Jul-03 3:13 
GeneralRe: Generic / Text Only print Pin
Ista24-Jul-03 6:52
Ista24-Jul-03 6:52 
GeneralRe: Generic / Text Only print Pin
MadsJ24-Jul-03 19:41
MadsJ24-Jul-03 19:41 
GeneralRe: Generic / Text Only print Pin
J. Dunlap24-Jul-03 20:13
J. Dunlap24-Jul-03 20:13 
GeneralRe: Generic / Text Only print Pin
Ista25-Jul-03 4:15
Ista25-Jul-03 4:15 
GeneralProcess Monitoring Pin
vikramlinux24-Jul-03 1:56
vikramlinux24-Jul-03 1:56 
GeneralRe: Process Monitoring Pin
Tom Archer24-Jul-03 2:18
Tom Archer24-Jul-03 2:18 
GeneralCreate Bitmap and LockBits Pin
novachen24-Jul-03 0:51
novachen24-Jul-03 0:51 
GeneralRe: Create Bitmap and LockBits Pin
leppie24-Jul-03 7:26
leppie24-Jul-03 7:26 
Questionhow to add component???? Pin
don7cry24-Jul-03 0:46
don7cry24-Jul-03 0:46 
Generalfunction parameter with default value Pin
zecodela23-Jul-03 23:17
zecodela23-Jul-03 23:17 
GeneralRe: function parameter with default value Pin
monrobot1324-Jul-03 2:37
monrobot1324-Jul-03 2:37 
GeneralRe: function parameter with default value Pin
Frank Olorin Rizzi24-Jul-03 3:26
Frank Olorin Rizzi24-Jul-03 3:26 
GeneralRe: function parameter with default value Pin
Tom Archer24-Jul-03 7:13
Tom Archer24-Jul-03 7:13 
GeneralRe: function parameter with default value Pin
leppie24-Jul-03 7:30
leppie24-Jul-03 7:30 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.