PC Review Forums Newsgroups Microsoft DotNet Microsoft ADO .NET Updating Access database

Reply

Updating Access database

 
Thread Tools Rate Thread
Old 09-02-2006, 06:32 PM   #1
Radi Radichev
Guest
 
Posts: n/a
Default Updating Access database


Hi!
I have a Typed Dataset dsPersonal1 and i try to update the database after i
edit a row in a datagrid bound to the dataset. Afret I execute
personalDataAdapter1.Update(dsPersonal1) the dataset is updated but not the
actual database.Can anyone tell me what am I doing wrong? I'm usinf Visual
C# Express and .net 2.0. Please explain me how do I update the actual
database...
Thanks!


  Reply With Quote
Old 09-02-2006, 07:06 PM   #2
W.G. Ryan - MVP
Guest
 
Posts: n/a
Default Re: Updating Access database

Radi:

The first thing to look at is to ensure that you Adapter is configured
correctly for Updates. Are you using the configuration wizard, the
commandbuilder, the enterprise library or did you write your own. If you're
using the Visual tools , make sure that all of the commands were generated
correctly at the end.

If they are, then you need to check the Rowstate of each row. When you call
Update, the adapter loops through the rows and checks the rowstate. If the
rowstate is deleted, then it uses the Adapter's Delete command and after
submitting the update, calls AcceptChanges on the row which resets the
rowstate on the row. It does the same for Inserts and Updates. However, if
you don't have Changes in your rows, then nothing gets submitted to the
server. One way to verify that is to trap the StateChanged event of the
connection and pop up a messagebox when the state changes. if you don't see
a messagebox then nothing go sent back tot he server (in Sql Server as
opposed to access, you can use Profiler but since you're not using Sql
Server, I just mention it in passing). The better way to check for changes
is to use Debug.Assert(dsPersonal1.HasChanges, "No Changes Are Present");
right before you call Update. If the assertion passes, then you have changes
and if the DB isn't getting updated, then the problem is almost certianly
with your commands themselves. If the assertion fails, then the problem is
that the UI isn't updating as you expected and more than likely, you need to
End the current edit of the row. You do this differently depending on how
you're binding things.

So first, verify that you have correct commands and more importantly, verify
that you have changes to be sumbitted. 99% of the time it's one or both of
these issues. if it isn't, let me know and we'll take it from there.

Cheers,

Bill
"Radi Radichev" <radi.radichev@uni-jena.de> wrote in message
news:OYR3ucaLGHA.4060@TK2MSFTNGP10.phx.gbl...
> Hi!
> I have a Typed Dataset dsPersonal1 and i try to update the database after
> i edit a row in a datagrid bound to the dataset. Afret I execute
> personalDataAdapter1.Update(dsPersonal1) the dataset is updated but not
> the actual database.Can anyone tell me what am I doing wrong? I'm usinf
> Visual C# Express and .net 2.0. Please explain me how do I update the
> actual database...
> Thanks!
>



  Reply With Quote
Old 09-02-2006, 07:18 PM   #3
Radi Radichev
Guest
 
Posts: n/a
Default Re: Updating Access database

Hi!
So first some info... So I'm adding a dataset to the solution explorer as a
new item. From there i choose my *.mdb file and then the table that i wish
to use. I then create a typed dataset using the wizard. Now i have two new
components in the toolbox. i add a personalTableAdapter and it gives me that
it has generated all needed commands including Update. Next i added a
binding source and set its datasource and data member properties
respectively to dsPersonal1 and personal(thats the tablename). i then add a
datagridview to the form. i use the dataadapters fill method to fill the
dataset on FormLoad event. It works fine. I then change a value and in the
FormClosing event i call the personalDataAdapter1.update(dsPersonal) method.
when i checked in debug mode for changes it returns a dataset with changes,
but when i close and the start the programm the changes are not there.... I
hope that helps you to understand what am I doing. Hope that you can help
me!


"W.G. Ryan - MVP" <WilliamRyan@nospam.gmail.com> wrote in message
news:epms%23taLGHA.532@TK2MSFTNGP15.phx.gbl...
> Radi:
>
> The first thing to look at is to ensure that you Adapter is configured
> correctly for Updates. Are you using the configuration wizard, the
> commandbuilder, the enterprise library or did you write your own. If
> you're using the Visual tools , make sure that all of the commands were
> generated correctly at the end.
>
> If they are, then you need to check the Rowstate of each row. When you
> call Update, the adapter loops through the rows and checks the rowstate.
> If the rowstate is deleted, then it uses the Adapter's Delete command and
> after submitting the update, calls AcceptChanges on the row which resets
> the rowstate on the row. It does the same for Inserts and Updates.
> However, if you don't have Changes in your rows, then nothing gets
> submitted to the server. One way to verify that is to trap the
> StateChanged event of the connection and pop up a messagebox when the
> state changes. if you don't see a messagebox then nothing go sent back tot
> he server (in Sql Server as opposed to access, you can use Profiler but
> since you're not using Sql Server, I just mention it in passing). The
> better way to check for changes is to use
> Debug.Assert(dsPersonal1.HasChanges, "No Changes Are Present"); right
> before you call Update. If the assertion passes, then you have changes and
> if the DB isn't getting updated, then the problem is almost certianly with
> your commands themselves. If the assertion fails, then the problem is
> that the UI isn't updating as you expected and more than likely, you need
> to End the current edit of the row. You do this differently depending on
> how you're binding things.
>
> So first, verify that you have correct commands and more importantly,
> verify that you have changes to be sumbitted. 99% of the time it's one or
> both of these issues. if it isn't, let me know and we'll take it from
> there.
>
> Cheers,
>
> Bill
> "Radi Radichev" <radi.radichev@uni-jena.de> wrote in message
> news:OYR3ucaLGHA.4060@TK2MSFTNGP10.phx.gbl...
>> Hi!
>> I have a Typed Dataset dsPersonal1 and i try to update the database after
>> i edit a row in a datagrid bound to the dataset. Afret I execute
>> personalDataAdapter1.Update(dsPersonal1) the dataset is updated but not
>> the actual database.Can anyone tell me what am I doing wrong? I'm usinf
>> Visual C# Express and .net 2.0. Please explain me how do I update the
>> actual database...
>> Thanks!
>>

>
>



  Reply With Quote
Old 09-02-2006, 09:22 PM   #4
W.G. Ryan - MVP
Guest
 
Posts: n/a
Default Re: Updating Access database

If changes are present and you're calling Update and the changes aren't
taking, the problem is likely with the update logic. Verify that you have a
key on your table first and that if you're using hte configuration wizard,
that all of the commands are correctly generated. You may need to call
EndCurrentEdit on the binding manager or the datasource so that it's not in
edit mode. Just to test this, go ahead and make your changes, then scroll
down creating a new row, don't put anything in it, then scroll back up to
the row you edited. Close the form and see if that doesn't fix it.
"Radi Radichev" <radi.radichev@uni-jena.de> wrote in message
news:emJkT2aLGHA.2036@TK2MSFTNGP14.phx.gbl...
> Hi!
> So first some info... So I'm adding a dataset to the solution explorer as
> a new item. From there i choose my *.mdb file and then the table that i
> wish to use. I then create a typed dataset using the wizard. Now i have
> two new components in the toolbox. i add a personalTableAdapter and it
> gives me that it has generated all needed commands including Update. Next
> i added a binding source and set its datasource and data member properties
> respectively to dsPersonal1 and personal(thats the tablename). i then add
> a datagridview to the form. i use the dataadapters fill method to fill the
> dataset on FormLoad event. It works fine. I then change a value and in the
> FormClosing event i call the personalDataAdapter1.update(dsPersonal)
> method. when i checked in debug mode for changes it returns a dataset with
> changes, but when i close and the start the programm the changes are not
> there.... I hope that helps you to understand what am I doing. Hope that
> you can help me!
>
>
> "W.G. Ryan - MVP" <WilliamRyan@nospam.gmail.com> wrote in message
> news:epms%23taLGHA.532@TK2MSFTNGP15.phx.gbl...
>> Radi:
>>
>> The first thing to look at is to ensure that you Adapter is configured
>> correctly for Updates. Are you using the configuration wizard, the
>> commandbuilder, the enterprise library or did you write your own. If
>> you're using the Visual tools , make sure that all of the commands were
>> generated correctly at the end.
>>
>> If they are, then you need to check the Rowstate of each row. When you
>> call Update, the adapter loops through the rows and checks the rowstate.
>> If the rowstate is deleted, then it uses the Adapter's Delete command and
>> after submitting the update, calls AcceptChanges on the row which resets
>> the rowstate on the row. It does the same for Inserts and Updates.
>> However, if you don't have Changes in your rows, then nothing gets
>> submitted to the server. One way to verify that is to trap the
>> StateChanged event of the connection and pop up a messagebox when the
>> state changes. if you don't see a messagebox then nothing go sent back
>> tot he server (in Sql Server as opposed to access, you can use Profiler
>> but since you're not using Sql Server, I just mention it in passing).
>> The better way to check for changes is to use
>> Debug.Assert(dsPersonal1.HasChanges, "No Changes Are Present"); right
>> before you call Update. If the assertion passes, then you have changes
>> and if the DB isn't getting updated, then the problem is almost certianly
>> with your commands themselves. If the assertion fails, then the problem
>> is that the UI isn't updating as you expected and more than likely, you
>> need to End the current edit of the row. You do this differently
>> depending on how you're binding things.
>>
>> So first, verify that you have correct commands and more importantly,
>> verify that you have changes to be sumbitted. 99% of the time it's one
>> or both of these issues. if it isn't, let me know and we'll take it from
>> there.
>>
>> Cheers,
>>
>> Bill
>> "Radi Radichev" <radi.radichev@uni-jena.de> wrote in message
>> news:OYR3ucaLGHA.4060@TK2MSFTNGP10.phx.gbl...
>>> Hi!
>>> I have a Typed Dataset dsPersonal1 and i try to update the database
>>> after i edit a row in a datagrid bound to the dataset. Afret I execute
>>> personalDataAdapter1.Update(dsPersonal1) the dataset is updated but not
>>> the actual database.Can anyone tell me what am I doing wrong? I'm usinf
>>> Visual C# Express and .net 2.0. Please explain me how do I update the
>>> actual database...
>>> Thanks!
>>>

>>
>>

>
>



  Reply With Quote
Old 09-02-2006, 10:15 PM   #5
Radi Radichev
Guest
 
Posts: n/a
Default Re: Updating Access database

Ahm I can't seem to fix it
I saw the update Command and ist seems fine.. I must add though that I call
the Personal form from another from. and when i close the personal form and
start it again without closing the main form the changes are there. but when
i clos the main form and run it again and call personal form there are no
changes... can this be the problem??

greetz
"W.G. Ryan - MVP" <WilliamRyan@nospam.gmail.com> wrote in message
news:udw5E6bLGHA.2064@TK2MSFTNGP09.phx.gbl...
> If changes are present and you're calling Update and the changes aren't
> taking, the problem is likely with the update logic. Verify that you have
> a key on your table first and that if you're using hte configuration
> wizard, that all of the commands are correctly generated. You may need to
> call EndCurrentEdit on the binding manager or the datasource so that it's
> not in edit mode. Just to test this, go ahead and make your changes, then
> scroll down creating a new row, don't put anything in it, then scroll back
> up to the row you edited. Close the form and see if that doesn't fix it.
> "Radi Radichev" <radi.radichev@uni-jena.de> wrote in message
> news:emJkT2aLGHA.2036@TK2MSFTNGP14.phx.gbl...
>> Hi!
>> So first some info... So I'm adding a dataset to the solution explorer as
>> a new item. From there i choose my *.mdb file and then the table that i
>> wish to use. I then create a typed dataset using the wizard. Now i have
>> two new components in the toolbox. i add a personalTableAdapter and it
>> gives me that it has generated all needed commands including Update. Next
>> i added a binding source and set its datasource and data member
>> properties respectively to dsPersonal1 and personal(thats the tablename).
>> i then add a datagridview to the form. i use the dataadapters fill method
>> to fill the dataset on FormLoad event. It works fine. I then change a
>> value and in the FormClosing event i call the
>> personalDataAdapter1.update(dsPersonal) method. when i checked in debug
>> mode for changes it returns a dataset with changes, but when i close and
>> the start the programm the changes are not there.... I hope that helps
>> you to understand what am I doing. Hope that you can help me!
>>
>>
>> "W.G. Ryan - MVP" <WilliamRyan@nospam.gmail.com> wrote in message
>> news:epms%23taLGHA.532@TK2MSFTNGP15.phx.gbl...
>>> Radi:
>>>
>>> The first thing to look at is to ensure that you Adapter is configured
>>> correctly for Updates. Are you using the configuration wizard, the
>>> commandbuilder, the enterprise library or did you write your own. If
>>> you're using the Visual tools , make sure that all of the commands were
>>> generated correctly at the end.
>>>
>>> If they are, then you need to check the Rowstate of each row. When you
>>> call Update, the adapter loops through the rows and checks the rowstate.
>>> If the rowstate is deleted, then it uses the Adapter's Delete command
>>> and after submitting the update, calls AcceptChanges on the row which
>>> resets the rowstate on the row. It does the same for Inserts and
>>> Updates. However, if you don't have Changes in your rows, then nothing
>>> gets submitted to the server. One way to verify that is to trap the
>>> StateChanged event of the connection and pop up a messagebox when the
>>> state changes. if you don't see a messagebox then nothing go sent back
>>> tot he server (in Sql Server as opposed to access, you can use Profiler
>>> but since you're not using Sql Server, I just mention it in passing).
>>> The better way to check for changes is to use
>>> Debug.Assert(dsPersonal1.HasChanges, "No Changes Are Present"); right
>>> before you call Update. If the assertion passes, then you have changes
>>> and if the DB isn't getting updated, then the problem is almost
>>> certianly with your commands themselves. If the assertion fails, then
>>> the problem is that the UI isn't updating as you expected and more than
>>> likely, you need to End the current edit of the row. You do this
>>> differently depending on how you're binding things.
>>>
>>> So first, verify that you have correct commands and more importantly,
>>> verify that you have changes to be sumbitted. 99% of the time it's one
>>> or both of these issues. if it isn't, let me know and we'll take it from
>>> there.
>>>
>>> Cheers,
>>>
>>> Bill
>>> "Radi Radichev" <radi.radichev@uni-jena.de> wrote in message
>>> news:OYR3ucaLGHA.4060@TK2MSFTNGP10.phx.gbl...
>>>> Hi!
>>>> I have a Typed Dataset dsPersonal1 and i try to update the database
>>>> after i edit a row in a datagrid bound to the dataset. Afret I execute
>>>> personalDataAdapter1.Update(dsPersonal1) the dataset is updated but not
>>>> the actual database.Can anyone tell me what am I doing wrong? I'm usinf
>>>> Visual C# Express and .net 2.0. Please explain me how do I update the
>>>> actual database...
>>>> Thanks!
>>>>
>>>
>>>

>>
>>

>
>



  Reply With Quote
Old 09-02-2006, 10:19 PM   #6
Radi Radichev
Guest
 
Posts: n/a
Default Re: Updating Access database

If it helps i can post the Update SQL string so you can see if it is
correct?


"Radi Radichev" <radi.radichev@uni-jena.de> wrote in message
news:OC9zfZcLGHA.3492@TK2MSFTNGP09.phx.gbl...
> Ahm I can't seem to fix it
> I saw the update Command and ist seems fine.. I must add though that I
> call the Personal form from another from. and when i close the personal
> form and start it again without closing the main form the changes are
> there. but when i clos the main form and run it again and call personal
> form there are no changes... can this be the problem??
>
> greetz
> "W.G. Ryan - MVP" <WilliamRyan@nospam.gmail.com> wrote in message
> news:udw5E6bLGHA.2064@TK2MSFTNGP09.phx.gbl...
>> If changes are present and you're calling Update and the changes aren't
>> taking, the problem is likely with the update logic. Verify that you
>> have a key on your table first and that if you're using hte configuration
>> wizard, that all of the commands are correctly generated. You may need
>> to call EndCurrentEdit on the binding manager or the datasource so that
>> it's not in edit mode. Just to test this, go ahead and make your changes,
>> then scroll down creating a new row, don't put anything in it, then
>> scroll back up to the row you edited. Close the form and see if that
>> doesn't fix it.
>> "Radi Radichev" <radi.radichev@uni-jena.de> wrote in message
>> news:emJkT2aLGHA.2036@TK2MSFTNGP14.phx.gbl...
>>> Hi!
>>> So first some info... So I'm adding a dataset to the solution explorer
>>> as a new item. From there i choose my *.mdb file and then the table that
>>> i wish to use. I then create a typed dataset using the wizard. Now i
>>> have two new components in the toolbox. i add a personalTableAdapter and
>>> it gives me that it has generated all needed commands including Update.
>>> Next i added a binding source and set its datasource and data member
>>> properties respectively to dsPersonal1 and personal(thats the
>>> tablename). i then add a datagridview to the form. i use the
>>> dataadapters fill method to fill the dataset on FormLoad event. It works
>>> fine. I then change a value and in the FormClosing event i call the
>>> personalDataAdapter1.update(dsPersonal) method. when i checked in debug
>>> mode for changes it returns a dataset with changes, but when i close and
>>> the start the programm the changes are not there.... I hope that helps
>>> you to understand what am I doing. Hope that you can help me!
>>>
>>>
>>> "W.G. Ryan - MVP" <WilliamRyan@nospam.gmail.com> wrote in message
>>> news:epms%23taLGHA.532@TK2MSFTNGP15.phx.gbl...
>>>> Radi:
>>>>
>>>> The first thing to look at is to ensure that you Adapter is configured
>>>> correctly for Updates. Are you using the configuration wizard, the
>>>> commandbuilder, the enterprise library or did you write your own. If
>>>> you're using the Visual tools , make sure that all of the commands were
>>>> generated correctly at the end.
>>>>
>>>> If they are, then you need to check the Rowstate of each row. When you
>>>> call Update, the adapter loops through the rows and checks the
>>>> rowstate. If the rowstate is deleted, then it uses the Adapter's Delete
>>>> command and after submitting the update, calls AcceptChanges on the row
>>>> which resets the rowstate on the row. It does the same for Inserts and
>>>> Updates. However, if you don't have Changes in your rows, then nothing
>>>> gets submitted to the server. One way to verify that is to trap the
>>>> StateChanged event of the connection and pop up a messagebox when the
>>>> state changes. if you don't see a messagebox then nothing go sent back
>>>> tot he server (in Sql Server as opposed to access, you can use Profiler
>>>> but since you're not using Sql Server, I just mention it in passing).
>>>> The better way to check for changes is to use
>>>> Debug.Assert(dsPersonal1.HasChanges, "No Changes Are Present"); right
>>>> before you call Update. If the assertion passes, then you have changes
>>>> and if the DB isn't getting updated, then the problem is almost
>>>> certianly with your commands themselves. If the assertion fails, then
>>>> the problem is that the UI isn't updating as you expected and more than
>>>> likely, you need to End the current edit of the row. You do this
>>>> differently depending on how you're binding things.
>>>>
>>>> So first, verify that you have correct commands and more importantly,
>>>> verify that you have changes to be sumbitted. 99% of the time it's one
>>>> or both of these issues. if it isn't, let me know and we'll take it
>>>> from there.
>>>>
>>>> Cheers,
>>>>
>>>> Bill
>>>> "Radi Radichev" <radi.radichev@uni-jena.de> wrote in message
>>>> news:OYR3ucaLGHA.4060@TK2MSFTNGP10.phx.gbl...
>>>>> Hi!
>>>>> I have a Typed Dataset dsPersonal1 and i try to update the database
>>>>> after i edit a row in a datagrid bound to the dataset. Afret I execute
>>>>> personalDataAdapter1.Update(dsPersonal1) the dataset is updated but
>>>>> not the actual database.Can anyone tell me what am I doing wrong? I'm
>>>>> usinf Visual C# Express and .net 2.0. Please explain me how do I
>>>>> update the actual database...
>>>>> Thanks!
>>>>>
>>>>
>>>>
>>>
>>>

>>
>>

>
>



  Reply With Quote
Old 09-02-2006, 10:38 PM   #7
W.G. Ryan - MVP
Guest
 
Posts: n/a
Default Re: Updating Access database

When you say the changes are there, then aren't, is the same dataset being
used (the same instance) or do you fill it each time when the form opens?
"Radi Radichev" <radi.radichev@uni-jena.de> wrote in message
news:OC9zfZcLGHA.3492@TK2MSFTNGP09.phx.gbl...
> Ahm I can't seem to fix it
> I saw the update Command and ist seems fine.. I must add though that I
> call the Personal form from another from. and when i close the personal
> form and start it again without closing the main form the changes are
> there. but when i clos the main form and run it again and call personal
> form there are no changes... can this be the problem??
>
> greetz
> "W.G. Ryan - MVP" <WilliamRyan@nospam.gmail.com> wrote in message
> news:udw5E6bLGHA.2064@TK2MSFTNGP09.phx.gbl...
>> If changes are present and you're calling Update and the changes aren't
>> taking, the problem is likely with the update logic. Verify that you
>> have a key on your table first and that if you're using hte configuration
>> wizard, that all of the commands are correctly generated. You may need
>> to call EndCurrentEdit on the binding manager or the datasource so that
>> it's not in edit mode. Just to test this, go ahead and make your changes,
>> then scroll down creating a new row, don't put anything in it, then
>> scroll back up to the row you edited. Close the form and see if that
>> doesn't fix it.
>> "Radi Radichev" <radi.radichev@uni-jena.de> wrote in message
>> news:emJkT2aLGHA.2036@TK2MSFTNGP14.phx.gbl...
>>> Hi!
>>> So first some info... So I'm adding a dataset to the solution explorer
>>> as a new item. From there i choose my *.mdb file and then the table that
>>> i wish to use. I then create a typed dataset using the wizard. Now i
>>> have two new components in the toolbox. i add a personalTableAdapter and
>>> it gives me that it has generated all needed commands including Update.
>>> Next i added a binding source and set its datasource and data member
>>> properties respectively to dsPersonal1 and personal(thats the
>>> tablename). i then add a datagridview to the form. i use the
>>> dataadapters fill method to fill the dataset on FormLoad event. It works
>>> fine. I then change a value and in the FormClosing event i call the
>>> personalDataAdapter1.update(dsPersonal) method. when i checked in debug
>>> mode for changes it returns a dataset with changes, but when i close and
>>> the start the programm the changes are not there.... I hope that helps
>>> you to understand what am I doing. Hope that you can help me!
>>>
>>>
>>> "W.G. Ryan - MVP" <WilliamRyan@nospam.gmail.com> wrote in message
>>> news:epms%23taLGHA.532@TK2MSFTNGP15.phx.gbl...
>>>> Radi:
>>>>
>>>> The first thing to look at is to ensure that you Adapter is configured
>>>> correctly for Updates. Are you using the configuration wizard, the
>>>> commandbuilder, the enterprise library or did you write your own. If
>>>> you're using the Visual tools , make sure that all of the commands were
>>>> generated correctly at the end.
>>>>
>>>> If they are, then you need to check the Rowstate of each row. When you
>>>> call Update, the adapter loops through the rows and checks the
>>>> rowstate. If the rowstate is deleted, then it uses the Adapter's Delete
>>>> command and after submitting the update, calls AcceptChanges on the row
>>>> which resets the rowstate on the row. It does the same for Inserts and
>>>> Updates. However, if you don't have Changes in your rows, then nothing
>>>> gets submitted to the server. One way to verify that is to trap the
>>>> StateChanged event of the connection and pop up a messagebox when the
>>>> state changes. if you don't see a messagebox then nothing go sent back
>>>> tot he server (in Sql Server as opposed to access, you can use Profiler
>>>> but since you're not using Sql Server, I just mention it in passing).
>>>> The better way to check for changes is to use
>>>> Debug.Assert(dsPersonal1.HasChanges, "No Changes Are Present"); right
>>>> before you call Update. If the assertion passes, then you have changes
>>>> and if the DB isn't getting updated, then the problem is almost
>>>> certianly with your commands themselves. If the assertion fails, then
>>>> the problem is that the UI isn't updating as you expected and more than
>>>> likely, you need to End the current edit of the row. You do this
>>>> differently depending on how you're binding things.
>>>>
>>>> So first, verify that you have correct commands and more importantly,
>>>> verify that you have changes to be sumbitted. 99% of the time it's one
>>>> or both of these issues. if it isn't, let me know and we'll take it
>>>> from there.
>>>>
>>>> Cheers,
>>>>
>>>> Bill
>>>> "Radi Radichev" <radi.radichev@uni-jena.de> wrote in message
>>>> news:OYR3ucaLGHA.4060@TK2MSFTNGP10.phx.gbl...
>>>>> Hi!
>>>>> I have a Typed Dataset dsPersonal1 and i try to update the database
>>>>> after i edit a row in a datagrid bound to the dataset. Afret I execute
>>>>> personalDataAdapter1.Update(dsPersonal1) the dataset is updated but
>>>>> not the actual database.Can anyone tell me what am I doing wrong? I'm
>>>>> usinf Visual C# Express and .net 2.0. Please explain me how do I
>>>>> update the actual database...
>>>>> Thanks!
>>>>>
>>>>
>>>>
>>>
>>>

>>
>>

>
>



  Reply With Quote
Old 09-02-2006, 10:39 PM   #8
W.G. Ryan - MVP
Guest
 
Posts: n/a
Default Re: Updating Access database

that might help but it's also the column mappings with the parameters. How
did you get the Update command, did you code it yourself or did you was it
generated for you? If the latter, with what?
"Radi Radichev" <radi.radichev@uni-jena.de> wrote in message
news:%23pXq1bcLGHA.3936@TK2MSFTNGP10.phx.gbl...
> If it helps i can post the Update SQL string so you can see if it is
> correct?
>
>
> "Radi Radichev" <radi.radichev@uni-jena.de> wrote in message
> news:OC9zfZcLGHA.3492@TK2MSFTNGP09.phx.gbl...
>> Ahm I can't seem to fix it
>> I saw the update Command and ist seems fine.. I must add though that I
>> call the Personal form from another from. and when i close the personal
>> form and start it again without closing the main form the changes are
>> there. but when i clos the main form and run it again and call personal
>> form there are no changes... can this be the problem??
>>
>> greetz
>> "W.G. Ryan - MVP" <WilliamRyan@nospam.gmail.com> wrote in message
>> news:udw5E6bLGHA.2064@TK2MSFTNGP09.phx.gbl...
>>> If changes are present and you're calling Update and the changes aren't
>>> taking, the problem is likely with the update logic. Verify that you
>>> have a key on your table first and that if you're using hte
>>> configuration wizard, that all of the commands are correctly generated.
>>> You may need to call EndCurrentEdit on the binding manager or the
>>> datasource so that it's not in edit mode. Just to test this, go ahead
>>> and make your changes, then scroll down creating a new row, don't put
>>> anything in it, then scroll back up to the row you edited. Close the
>>> form and see if that doesn't fix it.
>>> "Radi Radichev" <radi.radichev@uni-jena.de> wrote in message
>>> news:emJkT2aLGHA.2036@TK2MSFTNGP14.phx.gbl...
>>>> Hi!
>>>> So first some info... So I'm adding a dataset to the solution explorer
>>>> as a new item. From there i choose my *.mdb file and then the table
>>>> that i wish to use. I then create a typed dataset using the wizard. Now
>>>> i have two new components in the toolbox. i add a personalTableAdapter
>>>> and it gives me that it has generated all needed commands including
>>>> Update. Next i added a binding source and set its datasource and data
>>>> member properties respectively to dsPersonal1 and personal(thats the
>>>> tablename). i then add a datagridview to the form. i use the
>>>> dataadapters fill method to fill the dataset on FormLoad event. It
>>>> works fine. I then change a value and in the FormClosing event i call
>>>> the personalDataAdapter1.update(dsPersonal) method. when i checked in
>>>> debug mode for changes it returns a dataset with changes, but when i
>>>> close and the start the programm the changes are not there.... I hope
>>>> that helps you to understand what am I doing. Hope that you can help
>>>> me!
>>>>
>>>>
>>>> "W.G. Ryan - MVP" <WilliamRyan@nospam.gmail.com> wrote in message
>>>> news:epms%23taLGHA.532@TK2MSFTNGP15.phx.gbl...
>>>>> Radi:
>>>>>
>>>>> The first thing to look at is to ensure that you Adapter is configured
>>>>> correctly for Updates. Are you using the configuration wizard, the
>>>>> commandbuilder, the enterprise library or did you write your own. If
>>>>> you're using the Visual tools , make sure that all of the commands
>>>>> were generated correctly at the end.
>>>>>
>>>>> If they are, then you need to check the Rowstate of each row. When
>>>>> you call Update, the adapter loops through the rows and checks the
>>>>> rowstate. If the rowstate is deleted, then it uses the Adapter's
>>>>> Delete command and after submitting the update, calls AcceptChanges on
>>>>> the row which resets the rowstate on the row. It does the same for
>>>>> Inserts and Updates. However, if you don't have Changes in your rows,
>>>>> then nothing gets submitted to the server. One way to verify that is
>>>>> to trap the StateChanged event of the connection and pop up a
>>>>> messagebox when the state changes. if you don't see a messagebox then
>>>>> nothing go sent back tot he server (in Sql Server as opposed to
>>>>> access, you can use Profiler but since you're not using Sql Server, I
>>>>> just mention it in passing). The better way to check for changes is to
>>>>> use Debug.Assert(dsPersonal1.HasChanges, "No Changes Are Present");
>>>>> right before you call Update. If the assertion passes, then you have
>>>>> changes and if the DB isn't getting updated, then the problem is
>>>>> almost certianly with your commands themselves. If the assertion
>>>>> fails, then the problem is that the UI isn't updating as you expected
>>>>> and more than likely, you need to End the current edit of the row.
>>>>> You do this differently depending on how you're binding things.
>>>>>
>>>>> So first, verify that you have correct commands and more importantly,
>>>>> verify that you have changes to be sumbitted. 99% of the time it's
>>>>> one or both of these issues. if it isn't, let me know and we'll take
>>>>> it from there.
>>>>>
>>>>> Cheers,
>>>>>
>>>>> Bill
>>>>> "Radi Radichev" <radi.radichev@uni-jena.de> wrote in message
>>>>> news:OYR3ucaLGHA.4060@TK2MSFTNGP10.phx.gbl...
>>>>>> Hi!
>>>>>> I have a Typed Dataset dsPersonal1 and i try to update the database
>>>>>> after i edit a row in a datagrid bound to the dataset. Afret I
>>>>>> execute personalDataAdapter1.Update(dsPersonal1) the dataset is
>>>>>> updated but not the actual database.Can anyone tell me what am I
>>>>>> doing wrong? I'm usinf Visual C# Express and .net 2.0. Please explain
>>>>>> me how do I update the actual database...
>>>>>> Thanks!
>>>>>>
>>>>>
>>>>>
>>>>
>>>>
>>>
>>>

>>
>>

>
>



  Reply With Quote
Old 09-02-2006, 10:47 PM   #9
Radi Radichev
Guest
 
Posts: n/a
Default Re: Updating Access database

I use this to open the personal form:
frmPersonal PersonalForm = new frmPersonal();

PersonalForm.Show();

PersonalForm.Activate();

And then in the Onload Method of Personal form i call
the Fill Method. So an instance is created everythime i open the Personal
form..

The update command is generated when i create my typed dataset. When i open
the dsPersonal1.xsd in visual studio and click on configure it generates all
commands automaticly. I can't show you the complete code. it is very much.
but the update command is here:

UPDATE `personal` SET `prs_name` = ?, `prs_egn` = ?, `prs_address` = ?,
`prs_city` = ?, `prs_postalcode` = ?, `prs_pidnum` = ?, `prs_pidvalid` = ?,
`prs_passport` = ?, `prs_passvalid` = ?, `prs_birthdate` = ? WHERE
((`prs_id` = ?) AND ((? = 1 AND `prs_name` IS NULL) OR (`prs_name` = ?)) AND
((? = 1 AND `prs_egn` IS NULL) OR (`prs_egn` = ?)) AND ((? = 1 AND
`prs_address` IS NULL) OR (`prs_address` = ?)) AND ((? = 1 AND `prs_city` IS
NULL) OR (`prs_city` = ?)) AND ((? = 1 AND `prs_postalcode` IS NULL) OR
(`prs_postalcode` = ?)) AND ((? = 1 AND `prs_pidnum` IS NULL) OR
(`prs_pidnum` = ?)) AND ((? = 1 AND `prs_pidvalid` IS NULL) OR
(`prs_pidvalid` = ?)) AND ((? = 1 AND `prs_passport` IS NULL) OR
(`prs_passport` = ?)) AND ((? = 1 AND `prs_passvalid` IS NULL) OR
(`prs_passvalid` = ?)) AND ((? = 1 AND `prs_birthdate` IS NULL) OR
(`prs_birthdate` = ?)))



"W.G. Ryan - MVP"
<WilliamRyan@nospam.gmail.com> wrote in message
news:uqfZ2kcLGHA.2904@TK2MSFTNGP10.phx.gbl...
> that might help but it's also the column mappings with the parameters.
> How did you get the Update command, did you code it yourself or did you
> was it generated for you? If the latter, with what?
> "Radi Radichev" <radi.radichev@uni-jena.de> wrote in message
> news:%23pXq1bcLGHA.3936@TK2MSFTNGP10.phx.gbl...
>> If it helps i can post the Update SQL string so you can see if it is
>> correct?
>>
>>
>> "Radi Radichev" <radi.radichev@uni-jena.de> wrote in message
>> news:OC9zfZcLGHA.3492@TK2MSFTNGP09.phx.gbl...
>>> Ahm I can't seem to fix it
>>> I saw the update Command and ist seems fine.. I must add though that I
>>> call the Personal form from another from. and when i close the personal
>>> form and start it again without closing the main form the changes are
>>> there. but when i clos the main form and run it again and call personal
>>> form there are no changes... can this be the problem??
>>>
>>> greetz
>>> "W.G. Ryan - MVP" <WilliamRyan@nospam.gmail.com> wrote in message
>>> news:udw5E6bLGHA.2064@TK2MSFTNGP09.phx.gbl...
>>>> If changes are present and you're calling Update and the changes aren't
>>>> taking, the problem is likely with the update logic. Verify that you
>>>> have a key on your table first and that if you're using hte
>>>> configuration wizard, that all of the commands are correctly generated.
>>>> You may need to call EndCurrentEdit on the binding manager or the
>>>> datasource so that it's not in edit mode. Just to test this, go ahead
>>>> and make your changes, then scroll down creating a new row, don't put
>>>> anything in it, then scroll back up to the row you edited. Close the
>>>> form and see if that doesn't fix it.
>>>> "Radi Radichev" <radi.radichev@uni-jena.de> wrote in message
>>>> news:emJkT2aLGHA.2036@TK2MSFTNGP14.phx.gbl...
>>>>> Hi!
>>>>> So first some info... So I'm adding a dataset to the solution explorer
>>>>> as a new item. From there i choose my *.mdb file and then the table
>>>>> that i wish to use. I then create a typed dataset using the wizard.
>>>>> Now i have two new components in the toolbox. i add a
>>>>> personalTableAdapter and it gives me that it has generated all needed
>>>>> commands including Update. Next i added a binding source and set its
>>>>> datasource and data member properties respectively to dsPersonal1 and
>>>>> personal(thats the tablename). i then add a datagridview to the form.
>>>>> i use the dataadapters fill method to fill the dataset on FormLoad
>>>>> event. It works fine. I then change a value and in the FormClosing
>>>>> event i call the personalDataAdapter1.update(dsPersonal) method. when
>>>>> i checked in debug mode for changes it returns a dataset with changes,
>>>>> but when i close and the start the programm the changes are not
>>>>> there.... I hope that helps you to understand what am I doing. Hope
>>>>> that you can help me!
>>>>>
>>>>>
>>>>> "W.G. Ryan - MVP" <WilliamRyan@nospam.gmail.com> wrote in message
>>>>> news:epms%23taLGHA.532@TK2MSFTNGP15.phx.gbl...
>>>>>> Radi:
>>>>>>
>>>>>> The first thing to look at is to ensure that you Adapter is
>>>>>> configured correctly for Updates. Are you using the configuration
>>>>>> wizard, the commandbuilder, the enterprise library or did you write
>>>>>> your own. If you're using the Visual tools , make sure that all of
>>>>>> the commands were generated correctly at the end.
>>>>>>
>>>>>> If they are, then you need to check the Rowstate of each row. When
>>>>>> you call Update, the adapter loops through the rows and checks the
>>>>>> rowstate. If the rowstate is deleted, then it uses the Adapter's
>>>>>> Delete command and after submitting the update, calls AcceptChanges
>>>>>> on the row which resets the rowstate on the row. It does the same for
>>>>>> Inserts and Updates. However, if you don't have Changes in your rows,
>>>>>> then nothing gets submitted to the server. One way to verify that is
>>>>>> to trap the StateChanged event of the connection and pop up a
>>>>>> messagebox when the state changes. if you don't see a messagebox then
>>>>>> nothing go sent back tot he server (in Sql Server as opposed to
>>>>>> access, you can use Profiler but since you're not using Sql Server, I
>>>>>> just mention it in passing). The better way to check for changes is
>>>>>> to use Debug.Assert(dsPersonal1.HasChanges, "No Changes Are
>>>>>> Present"); right before you call Update. If the assertion passes,
>>>>>> then you have changes and if the DB isn't getting updated, then the
>>>>>> problem is almost certianly with your commands themselves. If the
>>>>>> assertion fails, then the problem is that the UI isn't updating as
>>>>>> you expected and more than likely, you need to End the current edit
>>>>>> of the row. You do this differently depending on how you're binding
>>>>>> things.
>>>>>>
>>>>>> So first, verify that you have correct commands and more importantly,
>>>>>> verify that you have changes to be sumbitted. 99% of the time it's
>>>>>> one or both of these issues. if it isn't, let me know and we'll take
>>>>>> it from there.
>>>>>>
>>>>>> Cheers,
>>>>>>
>>>>>> Bill
>>>>>> "Radi Radichev" <radi.radichev@uni-jena.de> wrote in message
>>>>>> news:OYR3ucaLGHA.4060@TK2MSFTNGP10.phx.gbl...
>>>>>>> Hi!
>>>>>>> I have a Typed Dataset dsPersonal1 and i try to update the database
>>>>>>> after i edit a row in a datagrid bound to the dataset. Afret I
>>>>>>> execute personalDataAdapter1.Update(dsPersonal1) the dataset is
>>>>>>> updated but not the actual database.Can anyone tell me what am I
>>>>>>> doing wrong? I'm usinf Visual C# Express and .net 2.0. Please
>>>>>>> explain me how do I update the actual database...
>>>>>>> Thanks!
>>>>>>>
>>>>>>
>>>>>>
>>>>>
>>>>>
>>>>
>>>>
>>>
>>>

>>
>>

>
>



  Reply With Quote
Old 10-02-2006, 12:54 AM   #10
Radi Radichev
Guest
 
Posts: n/a
Default Re: Updating Access database

I've changed my Update Query and when i execute it it runs perfectly but i
still can't update the database when i close the program.... Any Ideas??


"W.G. Ryan - MVP" <WilliamRyan@nospam.gmail.com> wrote in message
news:OX8uTkcLGHA.1132@TK2MSFTNGP10.phx.gbl...
> When you say the changes are there, then aren't, is the same dataset being
> used (the same instance) or do you fill it each time when the form opens?
> "Radi Radichev" <radi.radichev@uni-jena.de> wrote in message
> news:OC9zfZcLGHA.3492@TK2MSFTNGP09.phx.gbl...
>> Ahm I can't seem to fix it
>> I saw the update Command and ist seems fine.. I must add though that I
>> call the Personal form from another from. and when i close the personal
>> form and start it again without closing the main form the changes are
>> there. but when i clos the main form and run it again and call personal
>> form there are no changes... can this be the problem??
>>
>> greetz
>> "W.G. Ryan - MVP" <WilliamRyan@nospam.gmail.com> wrote in message
>> news:udw5E6bLGHA.2064@TK2MSFTNGP09.phx.gbl...
>>> If changes are present and you're calling Update and the changes aren't
>>> taking, the problem is likely with the update logic. Verify that you
>>> have a key on your table first and that if you're using hte
>>> configuration wizard, that all of the commands are correctly generated.
>>> You may need to call EndCurrentEdit on the binding manager or the
>>> datasource so that it's not in edit mode. Just to test this, go ahead
>>> and make your changes, then scroll down creating a new row, don't put
>>> anything in it, then scroll back up to the row you edited. Close the
>>> form and see if that doesn't fix it.
>>> "Radi Radichev" <radi.radichev@uni-jena.de> wrote in message
>>> news:emJkT2aLGHA.2036@TK2MSFTNGP14.phx.gbl...
>>>> Hi!
>>>> So first some info... So I'm adding a dataset to the solution explorer
>>>> as a new item. From there i choose my *.mdb file and then the table
>>>> that i wish to use. I then create a typed dataset using the wizard. Now
>>>> i have two new components in the toolbox. i add a personalTableAdapter
>>>> and it gives me that it has generated all needed commands including
>>>> Update. Next i added a binding source and set its datasource and data
>>>> member properties respectively to dsPersonal1 and personal(thats the
>>>> tablename). i then add a datagridview to the form. i use the
>>>> dataadapters fill method to fill the dataset on FormLoad event. It
>>>> works fine. I then change a value and in the FormClosing event i call
>>>> the personalDataAdapter1.update(dsPersonal) method. when i checked in
>>>> debug mode for changes it returns a dataset with changes, but when i
>>>> close and the start the programm the changes are not there.... I hope
>>>> that helps you to understand what am I doing. Hope that you can help
>>>> me!
>>>>
>>>>
>>>> "W.G. Ryan - MVP" <WilliamRyan@nospam.gmail.com> wrote in message
>>>> news:epms%23taLGHA.532@TK2MSFTNGP15.phx.gbl...
>>>>> Radi:
>>>>>
>>>>> The first thing to look at is to ensure that you Adapter is configured
>>>>> correctly for Updates. Are you using the configuration wizard, the
>>>>> commandbuilder, the enterprise library or did you write your own. If
>>>>> you're using the Visual tools , make sure that all of the commands
>>>>> were generated correctly at the end.
>>>>>
>>>>> If they are, then you need to check the Rowstate of each row. When
>>>>> you call Update, the adapter loops through the rows and checks the
>>>>> rowstate. If the rowstate is deleted, then it uses the Adapter's
>>>>> Delete command and after submitting the update, calls AcceptChanges on
>>>>> the row which resets the rowstate on the row. It does the same for
>>>>> Inserts and Updates. However, if you don't have Changes in your rows,
>>>>> then nothing gets submitted to the server. One way to verify that is
>>>>> to trap the StateChanged event of the connection and pop up a
>>>>> messagebox when the state changes. if you don't see a messagebox then
>>>>> nothing go sent back tot he server (in Sql Server as opposed to
>>>>> access, you can use Profiler but since you're not using Sql Server, I
>>>>> just mention it in passing). The better way to check for changes is to
>>>>> use Debug.Assert(dsPersonal1.HasChanges, "No Changes Are Present");
>>>>> right before you call Update. If the assertion passes, then you have
>>>>> changes and if the DB isn't getting updated, then the problem is
>>>>> almost certianly with your commands themselves. If the assertion
>>>>> fails, then the problem is that the UI isn't updating as you expected
>>>>> and more than likely, you need to End the current edit of the row.
>>>>> You do this differently depending on how you're binding things.
>>>>>
>>>>> So first, verify that you have correct commands and more importantly,
>>>>> verify that you have changes to be sumbitted. 99% of the time it's
>>>>> one or both of these issues. if it isn't, let me know and we'll take
>>>>> it from there.
>>>>>
>>>>> Cheers,
>>>>>
>>>>> Bill
>>>>> "Radi Radichev" <radi.radichev@uni-jena.de> wrote in message
>>>>> news:OYR3ucaLGHA.4060@TK2MSFTNGP10.phx.gbl...
>>>>>> Hi!
>>>>>> I have a Typed Dataset dsPersonal1 and i try to update the database
>>>>>> after i edit a row in a datagrid bound to the dataset. Afret I
>>>>>> execute personalDataAdapter1.Update(dsPersonal1) the dataset is
>>>>>> updated but not the actual database.Can anyone tell me what am I
>>>>>> doing wrong? I'm usinf Visual C# Express and .net 2.0. Please explain
>>>>>> me how do I update the actual database...
>>>>>> Thanks!
>>>>>>
>>>>>
>>>>>
>>>>
>>>>
>>>
>>>

>>
>>

>
>



  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