Click here to Skip to main content
16,008,010 members
Home / Discussions / C#
   

C#

 
QuestionPlz help me convert .doc to any image format Pin
Petrus_Alex27-Mar-06 5:29
Petrus_Alex27-Mar-06 5:29 
QuestionMimic Mouse Click Pin
royk12327-Mar-06 5:29
royk12327-Mar-06 5:29 
AnswerRe: Mimic Mouse Click Pin
Glaxalg27-Mar-06 8:28
Glaxalg27-Mar-06 8:28 
GeneralRe: Mimic Mouse Click Pin
royk12327-Mar-06 17:05
royk12327-Mar-06 17:05 
QuestionToolbox Bug Pin
Dominik Reichl27-Mar-06 5:20
Dominik Reichl27-Mar-06 5:20 
AnswerRe: Toolbox Bug Pin
Jared Parsons27-Mar-06 19:27
Jared Parsons27-Mar-06 19:27 
QuestionFinding unsuccessful updates Pin
Mark0627-Mar-06 4:34
Mark0627-Mar-06 4:34 
AnswerRe: Finding unsuccessful updates Pin
Ricardo Casquete27-Mar-06 5:31
Ricardo Casquete27-Mar-06 5:31 
you have to play a bit with the RowState

I means, as you know, a DataTable is a collection of DataRows, each DataRow has a property called DataRowState, this value can be, CurrentRows, Inserted, Deleted... and so on.

In the moment you call the AcceptChanges of the DataSet ( or DataTable ) the DataRowState will be Current Rows, so you have to play with this before calling the DataAdapter.Update or the dataTable.AcceptChanges().

I send you code I did as sample for a fellow.

I hope it works

<br />
dstExample dst = new dstExample();<br />
dstExample.MyTableRow rowExample ;<br />
<br />
rowExample = dst.MyTable.NewMyTableRow();<br />
rowExample.MyField = "Field";<br />
dst.MyTable.Rows.Add ( rowExample );<br />
<br />
string s = rowExample.RowState.ToString();  // You will see the State is Added because the has just<br />
											// been Added to the dst.<br />
<br />
string t = dst.MyTable.Rows [ 0 ].RowState.ToString();  // This Row is the Same... the previous one, because the<br />
														// reference is still<br />
<br />
// So you have added a row, the state of this row is Added... if you NOW call UpdateDataSet, the row will <br />
// be inserted in the dataBase.<br />
<br />
bool h = dst.HasChanges ( ); // True , there is at least one row with changes<br />
bool j = dst.HasChanges ( System.Data.DataRowState.Added ); // True there is at least one Row that has been added<br />
bool a = dst.HasChanges ( System.Data.DataRowState.Modified ); // False, there is no Row Modified<br />
<br />
// If you call AcceptChanges(), the RowState will be UnChanges ( or UnModified ) I don´t remeber....<br />
// so if you call UpdateDataSet afterr call<br />
<br />
dst.MyTable.Rows [ 0 ].AcceptChanges(); // You Call Accept Changes over the Row. It means you only accept the changes<br />
										// of this Row... if you call dst.AcceptChanges(), means you accept all the changes <br />
										// the dataSet has.<br />
<br />
h = dst.HasChanges ( ); // False , there is no row with changes<br />
j = dst.HasChanges ( System.Data.DataRowState.Added ); // False, there is no row added<br />
<br />
t = dst.MyTable.Rows [ 0 ].RowState.ToString();  // You will see the State the state is UnModified.<br />
<br />
rowExample = dst.MyTable.NewMyTableRow();<br />
rowExample.MyField = "Field";<br />
dst.MyTable.Rows.Add ( rowExample );<br />
<br />
h = dst.HasChanges ( ); // True , there is at least one row with changes<br />
	<br />
rowExample = dst.MyTable.NewMyTableRow();<br />
rowExample.MyField = "Field";<br />
dst.MyTable.Rows.Add ( rowExample );<br />
<br />
dst.MyTable.Rows [ 2 ].AcceptChanges(); // Accept the Changes on the last row<br />
dst.MyTable.Rows [ 2 ][ 0 ] = "Value2"; // Modified the last row<br />
<br />
s = dst.MyTable.Rows [ 1 ].RowState.ToString();<br />
t = dst.MyTable.Rows [ 2 ].RowState.ToString();<br />
<br />
h = dst.HasChanges ( ); // True , there is at least one row with changes<br />
j = dst.HasChanges ( System.Data.DataRowState.Added ); // True there is at least one Row that has been added<br />
a = dst.HasChanges ( System.Data.DataRowState.Modified ); // True there is at least one Row that has been Modified<br />
<br />
// So if you call UpdateDataSet, <br />
//			for the first Row, nothing will happen because you called AcceptChanges<br />
//			for the Second Row, a Insert Sql Will be created, because the RowState is Added.<br />
//			for the first Row, a Update Sql will be created, because the RowState is Modified<br />
<br />



Regards


Ricardo Casquete
QuestionHow to cast an int to a String [novice] Pin
Inkimar27-Mar-06 4:29
Inkimar27-Mar-06 4:29 
AnswerRe: How to cast an int to a String [novice] Pin
Jimbo2227-Mar-06 4:38
Jimbo2227-Mar-06 4:38 
AnswerRe: How to cast an int to a String [novice] Pin
Stanciu Vlad27-Mar-06 4:59
Stanciu Vlad27-Mar-06 4:59 
QuestionC# for PDA Pin
hung_ngole27-Mar-06 4:02
hung_ngole27-Mar-06 4:02 
AnswerRe: C# for PDA Pin
Judah Gabriel Himango27-Mar-06 4:15
sponsorJudah Gabriel Himango27-Mar-06 4:15 
QuestionProblems with File Download Pin
SreekanthJ27-Mar-06 3:51
SreekanthJ27-Mar-06 3:51 
GeneralRe: Problems with File Download Pin
Guffa27-Mar-06 7:09
Guffa27-Mar-06 7:09 
QuestionPlease help about TableAdapter Pin
emran83427-Mar-06 3:32
emran83427-Mar-06 3:32 
QuestionLocalization Issue Pin
adityap27-Mar-06 3:13
adityap27-Mar-06 3:13 
AnswerRe: Localization Issue Pin
Ricardo Casquete27-Mar-06 4:24
Ricardo Casquete27-Mar-06 4:24 
QuestionTextbox enter Pin
Dave McCool27-Mar-06 2:57
Dave McCool27-Mar-06 2:57 
AnswerRe: Textbox enter Pin
albCode27-Mar-06 3:11
albCode27-Mar-06 3:11 
AnswerRe: Textbox enter Pin
Jimbo2227-Mar-06 5:06
Jimbo2227-Mar-06 5:06 
AnswerRe: Textbox enter Pin
Ricardo Casquete27-Mar-06 5:07
Ricardo Casquete27-Mar-06 5:07 
QuestionProblem in using Timers Pin
smadan27-Mar-06 2:56
smadan27-Mar-06 2:56 
AnswerRe: Problem in using Timers Pin
BlackDice27-Mar-06 7:25
BlackDice27-Mar-06 7:25 
QuestionRe: Problem in using Timers Pin
smadan27-Mar-06 18:49
smadan27-Mar-06 18:49 

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.