PC Review Forums Newsgroups Microsoft DotNet Microsoft ADO .NET Data Set Changes and Image importing

Reply

Data Set Changes and Image importing

 
Thread Tools Rate Thread
Old 11-02-2006, 08:25 AM   #1
Radi Radichev
Guest
 
Posts: n/a
Default Data Set Changes and Image importing


Hi!
I'm trying to check in the OnFormClosing event if the dataset has changes
that are still not commited and if yes to display a dialog box showing a
question if the user wants to save tha changes or not. I test it with
dataset.HasChanges() but it returns true even only when i change the record
with binding navigator... Does anybody know how to do this right?? Also how
can i load a picture in the database and display it in a imagecontrol?
Thanks!!!


  Reply With Quote
Old 11-02-2006, 10:12 AM   #2
Cor Ligthert [MVP]
Guest
 
Posts: n/a
Default Re: Data Set Changes and Image importing

Radi,

if (((DataSet)employeesBindingSource.DataSource).HasChanges() ) {
MessageBox.Show("There are changes");

if (northwindDataSet.HasChanges() ) {
MessageBox.Show("There are changes");

Both work fine for me.

I hope this helps,

Cor

"Radi Radichev" <radi.radichev@uni-jena.de> schreef in bericht
news:OxqToSuLGHA.2628@TK2MSFTNGP15.phx.gbl...
> Hi!
> I'm trying to check in the OnFormClosing event if the dataset has changes
> that are still not commited and if yes to display a dialog box showing a
> question if the user wants to save tha changes or not. I test it with
> dataset.HasChanges() but it returns true even only when i change the
> record
> with binding navigator... Does anybody know how to do this right?? Also
> how
> can i load a picture in the database and display it in a imagecontrol?
> Thanks!!!
>



  Reply With Quote
Old 11-02-2006, 04:49 PM   #3
Radi Radichev
Guest
 
Posts: n/a
Default Re: Data Set Changes and Image importing

Yeah I've tryed this. It still doesn't work correct.. When i change the
record with binding navigator without editing something it still gives me
that there are changes in the dataset... I'm testing it exactly as you
describe:
if(ds.HasChanges())
{
.....
}
Any ideas?


"Cor Ligthert [MVP]" <notmyfirstname@planet.nl> wrote in message
news:OZ1XTOvLGHA.1312@TK2MSFTNGP09.phx.gbl...
> Radi,
>
> if (((DataSet)employeesBindingSource.DataSource).HasChanges() ) {
> MessageBox.Show("There are changes");
>
> if (northwindDataSet.HasChanges() ) {
> MessageBox.Show("There are changes");
>
> Both work fine for me.
>
> I hope this helps,
>
> Cor
>
> "Radi Radichev" <radi.radichev@uni-jena.de> schreef in bericht
> news:OxqToSuLGHA.2628@TK2MSFTNGP15.phx.gbl...
>> Hi!
>> I'm trying to check in the OnFormClosing event if the dataset has changes
>> that are still not commited and if yes to display a dialog box showing a
>> question if the user wants to save tha changes or not. I test it with
>> dataset.HasChanges() but it returns true even only when i change the
>> record
>> with binding navigator... Does anybody know how to do this right?? Also
>> how
>> can i load a picture in the database and display it in a imagecontrol?
>> Thanks!!!
>>

>
>



  Reply With Quote
Old 12-02-2006, 06:42 AM   #4
Cor Ligthert [MVP]
Guest
 
Posts: n/a
Default Re: Data Set Changes and Image importing

Radi,

Than you should show more code, I gave you two working tested samples, I can
really not look at your code without that you show it to me.

Cor

"Radi Radichev" <radi.radichev@uni-jena.de> schreef in bericht
news:O4qSXsyLGHA.2668@tk2msftngp13.phx.gbl...
> Yeah I've tryed this. It still doesn't work correct.. When i change the
> record with binding navigator without editing something it still gives me
> that there are changes in the dataset... I'm testing it exactly as you
> describe:
> if(ds.HasChanges())
> {
> ....
> }
> Any ideas?
>
>
> "Cor Ligthert [MVP]" <notmyfirstname@planet.nl> wrote in message
> news:OZ1XTOvLGHA.1312@TK2MSFTNGP09.phx.gbl...
>> Radi,
>>
>> if (((DataSet)employeesBindingSource.DataSource).HasChanges() ) {
>> MessageBox.Show("There are changes");
>>
>> if (northwindDataSet.HasChanges() ) {
>> MessageBox.Show("There are changes");
>>
>> Both work fine for me.
>>
>> I hope this helps,
>>
>> Cor
>>
>> "Radi Radichev" <radi.radichev@uni-jena.de> schreef in bericht
>> news:OxqToSuLGHA.2628@TK2MSFTNGP15.phx.gbl...
>>> Hi!
>>> I'm trying to check in the OnFormClosing event if the dataset has
>>> changes
>>> that are still not commited and if yes to display a dialog box showing a
>>> question if the user wants to save tha changes or not. I test it with
>>> dataset.HasChanges() but it returns true even only when i change the
>>> record
>>> with binding navigator... Does anybody know how to do this right?? Also
>>> how
>>> can i load a picture in the database and display it in a imagecontrol?
>>> Thanks!!!
>>>

>>
>>

>
>



  Reply With Quote
Old 12-02-2006, 11:16 AM   #5
Radi Radichev
Guest
 
Posts: n/a
Default Re: Data Set Changes and Image importing

Oh well here's my code:
private void frmPersonal_FormClosing(object sender, FormClosingEventArgs e)

{

if (this.transcoDataSet.GetChanges()!=null)

{

DialogResult result;

result = MessageBox.Show(this, "blabla", "blablaba",
MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question,
MessageBoxDefaultButton.Button3);

if (result == DialogResult.Yes)

{

this.Validate();

this.personalBindingSource.EndEdit();

this.personalTableAdapter.Update(this.transcoDataSet.personal);

this.transcoDataSet.AcceptChanges();

}

else if (result == DialogResult.No)

e.Cancel = false;

else if (result == DialogResult.Cancel)

e.Cancel = true;

}

}




  Reply With Quote
Old 12-02-2006, 11:18 AM   #6
Radi Radichev
Guest
 
Posts: n/a
Default Re: Data Set Changes and Image importing

Ahm there is a mistake here..
its if(this.transcoDataSet.HasChanges())-----
"Radi Radichev" <radi.radichev@uni-jena.de> wrote in message
news:%23fykTX8LGHA.3196@TK2MSFTNGP09.phx.gbl...
> Oh well here's my code:
> private void frmPersonal_FormClosing(object sender, FormClosingEventArgs
> e)
>
> {
>
> if (this.transcoDataSet.GetChanges()!=null)
>
> {
>
> DialogResult result;
>
> result = MessageBox.Show(this, "blabla", "blablaba",
> MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question,
> MessageBoxDefaultButton.Button3);
>
> if (result == DialogResult.Yes)
>
> {
>
> this.Validate();
>
> this.personalBindingSource.EndEdit();
>
> this.personalTableAdapter.Update(this.transcoDataSet.personal);
>
> this.transcoDataSet.AcceptChanges();
>
> }
>
> else if (result == DialogResult.No)
>
> e.Cancel = false;
>
> else if (result == DialogResult.Cancel)
>
> e.Cancel = true;
>
> }
>
> }
>
>
>
>



  Reply With Quote
Old 12-02-2006, 11:53 AM   #7
Cor Ligthert [MVP]
Guest
 
Posts: n/a
Default Re: Data Set Changes and Image importing

Radi,

Can you try this one
transcoDataSet.Tables("yourtablename or the strongly typed
one).EndCurrentEdit();
> its if(this.transcoDataSet.HasChanges())-----


I hope this helps

Cor

> its if(this.transcoDataSet.HasChanges())-----
> "Radi Radichev" <radi.radichev@uni-jena.de> wrote in message
> news:%23fykTX8LGHA.3196@TK2MSFTNGP09.phx.gbl...
>> Oh well here's my code:
>> private void frmPersonal_FormClosing(object sender, FormClosingEventArgs
>> e)
>>
>> {
>>
>> if (this.transcoDataSet.GetChanges()!=null)
>>
>> {
>>
>> DialogResult result;
>>
>> result = MessageBox.Show(this, "blabla", "blablaba",
>> MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question,
>> MessageBoxDefaultButton.Button3);
>>
>> if (result == DialogResult.Yes)
>>
>> {
>>
>> this.Validate();
>>
>> this.personalBindingSource.EndEdit();
>>
>> this.personalTableAdapter.Update(this.transcoDataSet.personal);
>>
>> this.transcoDataSet.AcceptChanges();
>>
>> }
>>
>> else if (result == DialogResult.No)
>>
>> e.Cancel = false;
>>
>> else if (result == DialogResult.Cancel)
>>
>> e.Cancel = true;
>>
>> }
>>
>> }
>>
>>
>>
>>

>
>



  Reply With Quote
Old 12-02-2006, 12:45 PM   #8
Radi Radichev
Guest
 
Posts: n/a
Default Re: Data Set Changes and Image importing

Cor, I can't find such method...
Can you write this a little understandable pls?

"Cor Ligthert [MVP]" <notmyfirstname@planet.nl> wrote in message
news:e48XXr8LGHA.420@tk2msftngp13.phx.gbl...
> Radi,
>
> Can you try this one
> transcoDataSet.Tables("yourtablename or the strongly typed
> one).EndCurrentEdit();
>> its if(this.transcoDataSet.HasChanges())-----

>
> I hope this helps
>
> Cor
>
>> its if(this.transcoDataSet.HasChanges())-----
>> "Radi Radichev" <radi.radichev@uni-jena.de> wrote in message
>> news:%23fykTX8LGHA.3196@TK2MSFTNGP09.phx.gbl...
>>> Oh well here's my code:
>>> private void frmPersonal_FormClosing(object sender, FormClosingEventArgs
>>> e)
>>>
>>> {
>>>
>>> if (this.transcoDataSet.GetChanges()!=null)
>>>
>>> {
>>>
>>> DialogResult result;
>>>
>>> result = MessageBox.Show(this, "blabla", "blablaba",
>>> MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question,
>>> MessageBoxDefaultButton.Button3);
>>>
>>> if (result == DialogResult.Yes)
>>>
>>> {
>>>
>>> this.Validate();
>>>
>>> this.personalBindingSource.EndEdit();
>>>
>>> this.personalTableAdapter.Update(this.transcoDataSet.personal);
>>>
>>> this.transcoDataSet.AcceptChanges();
>>>
>>> }
>>>
>>> else if (result == DialogResult.No)
>>>
>>> e.Cancel = false;
>>>
>>> else if (result == DialogResult.Cancel)
>>>
>>> e.Cancel = true;
>>>
>>> }
>>>
>>> }
>>>
>>>
>>>
>>>

>>
>>

>
>



  Reply With Quote
Old 12-02-2006, 12:56 PM   #9
Cor Ligthert [MVP]
Guest
 
Posts: n/a
Default Re: Data Set Changes and Image importing

Radi,

Has to be brackets, it is a property.
transcoDataSet.Tables["yourtablename"].EndCurrentEdit();

(It was some mix between C# and VBCode at the end I did remember me that you
are using C#)

My keyboard is broken, I have now an old one however while typing with a
broken keyboard I had not much attention to the syntax, I was glad it was
typing.

:-)

Cor

"Radi Radichev" <radi.radichev@uni-jena.de> schreef in bericht
news:%23kAD8I9LGHA.3144@TK2MSFTNGP11.phx.gbl...
> Cor, I can't find such method...
> Can you write this a little understandable pls?
>
> "Cor Ligthert [MVP]" <notmyfirstname@planet.nl> wrote in message
> news:e48XXr8LGHA.420@tk2msftngp13.phx.gbl...
>> Radi,
>>
>> Can you try this one
>> transcoDataSet.Tables("yourtablename or the strongly typed
>> one).EndCurrentEdit();
>>> its if(this.transcoDataSet.HasChanges())-----

>>
>> I hope this helps
>>
>> Cor
>>
>>> its if(this.transcoDataSet.HasChanges())-----
>>> "Radi Radichev" <radi.radichev@uni-jena.de> wrote in message
>>> news:%23fykTX8LGHA.3196@TK2MSFTNGP09.phx.gbl...
>>>> Oh well here's my code:
>>>> private void frmPersonal_FormClosing(object sender,
>>>> FormClosingEventArgs e)
>>>>
>>>> {
>>>>
>>>> if (this.transcoDataSet.GetChanges()!=null)
>>>>
>>>> {
>>>>
>>>> DialogResult result;
>>>>
>>>> result = MessageBox.Show(this, "blabla", "blablaba",
>>>> MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question,
>>>> MessageBoxDefaultButton.Button3);
>>>>
>>>> if (result == DialogResult.Yes)
>>>>
>>>> {
>>>>
>>>> this.Validate();
>>>>
>>>> this.personalBindingSource.EndEdit();
>>>>
>>>> this.personalTableAdapter.Update(this.transcoDataSet.personal);
>>>>
>>>> this.transcoDataSet.AcceptChanges();
>>>>
>>>> }
>>>>
>>>> else if (result == DialogResult.No)
>>>>
>>>> e.Cancel = false;
>>>>
>>>> else if (result == DialogResult.Cancel)
>>>>
>>>> e.Cancel = true;
>>>>
>>>> }
>>>>
>>>> }
>>>>
>>>>
>>>>
>>>>
>>>
>>>

>>
>>

>
>



  Reply With Quote
Old 12-02-2006, 01:00 PM   #10
Radi Radichev
Guest
 
Posts: n/a
Default Re: Data Set Changes and Image importing

When I use the binding source to change the record to the next recort it
automaticly changes somehow the state to modified and when i check it with
HasChanges() it gives me true every time when i look another records.. I
can't find info on this in msdn....



"Radi Radichev" <radi.radichev@uni-jena.de> wrote in message
news:%23kAD8I9LGHA.3144@TK2MSFTNGP11.phx.gbl...
> Cor, I can't find such method...
> Can you write this a little understandable pls?
>
> "Cor Ligthert [MVP]" <notmyfirstname@planet.nl> wrote in message
> news:e48XXr8LGHA.420@tk2msftngp13.phx.gbl...
>> Radi,
>>
>> Can you try this one
>> transcoDataSet.Tables("yourtablename or the strongly typed
>> one).EndCurrentEdit();
>>> its if(this.transcoDataSet.HasChanges())-----

>>
>> I hope this helps
>>
>> Cor
>>
>>> its if(this.transcoDataSet.HasChanges())-----
>>> "Radi Radichev" <radi.radichev@uni-jena.de> wrote in message
>>> news:%23fykTX8LGHA.3196@TK2MSFTNGP09.phx.gbl...
>>>> Oh well here's my code:
>>>> private void frmPersonal_FormClosing(object sender,
>>>> FormClosingEventArgs e)
>>>>
>>>> {
>>>>
>>>> if (this.transcoDataSet.GetChanges()!=null)
>>>>
>>>> {
>>>>
>>>> DialogResult result;
>>>>
>>>> result = MessageBox.Show(this, "blabla", "blablaba",
>>>> MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question,
>>>> MessageBoxDefaultButton.Button3);
>>>>
>>>> if (result == DialogResult.Yes)
>>>>
>>>> {
>>>>
>>>> this.Validate();
>>>>
>>>> this.personalBindingSource.EndEdit();
>>>>
>>>> this.personalTableAdapter.Update(this.transcoDataSet.personal);
>>>>
>>>> this.transcoDataSet.AcceptChanges();
>>>>
>>>> }
>>>>
>>>> else if (result == DialogResult.No)
>>>>
>>>> e.Cancel = false;
>>>>
>>>> else if (result == DialogResult.Cancel)
>>>>
>>>> e.Cancel = true;
>>>>
>>>> }
>>>>
>>>> }
>>>>
>>>>
>>>>
>>>>
>>>
>>>

>>
>>

>
>



  Reply With Quote
Reply



Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off