Home All Groups Group Topic Archive Search About

Cannot update Access Database

Author
7 May 2009 2:13 AM
C a r l o s A n t o n i o
Sorry for the x-posting.  It's just I'm not sure which group this post is
related to.

Well,  I have an Access 2007 database (also tried with Access 2003 with no
success) and I am creating an application for my programming class (which is
due this week) using VB2008.  I am using Typed Datasets.  The thing is that
I cannot do a simple thing as updating a record.  I do not get error
messages either.  I will post the code, if anyone could help me, I will be
very grateful.

Thanks a lot for your help.

    Private Sub update_new_user_password()
        Try


            'Connection String in My.Settings:
            'Provider=Microsoft.ACE.OLEDB.12.0;Data
Source="|DataDirectory|\DAL\Databases\v2 communications.accdb";Persist
Security Info=True

            Dim ta As New
v2_communicationsDataSetTableAdapters.V2DataLoginTableAdapter
            Dim dt As v2_communicationsDataSet.V2DataLoginDataTable
            Dim row As v2_communicationsDataSet.V2DataLoginRow

            dt = ta.GetData

            row = dt.FindByUserNameID(str_username.Trim)
            With row
                .BeginEdit()
                Debug.Print(.UserNameID & ", " & .Password)
                .Password = texnewpassword.Text
                Debug.Print(.UserNameID & ", " & .Password)
                .EndEdit()
            End With

            ta.Update(dt)

        Catch ex As Exception
            MessageBox.Show(ex.Message, Application.ProductName,
MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
        End Try

    End Sub

Author
7 May 2009 5:05 AM
Cor Ligthert[MVP]
Carlos,

I don't see new, deleted or changed data.

Or I should misinterpret the method dt.GetData

Cor

Show quoteHide quote
"C a r l o s A n t o n i o" <carlvazpr¿arroba?yahoo.com> wrote in message
news:eqc2ylrzJHA.2480@TK2MSFTNGP06.phx.gbl...
> Sorry for the x-posting.  It's just I'm not sure which group this post is
> related to.
>
> Well,  I have an Access 2007 database (also tried with Access 2003 with no
> success) and I am creating an application for my programming class (which
> is due this week) using VB2008.  I am using Typed Datasets.  The thing is
> that I cannot do a simple thing as updating a record.  I do not get error
> messages either.  I will post the code, if anyone could help me, I will be
> very grateful.
>
> Thanks a lot for your help.
>
>    Private Sub update_new_user_password()
>        Try
>
>
>            'Connection String in My.Settings:
>            'Provider=Microsoft.ACE.OLEDB.12.0;Data
> Source="|DataDirectory|\DAL\Databases\v2 communications.accdb";Persist
> Security Info=True
>
>            Dim ta As New
> v2_communicationsDataSetTableAdapters.V2DataLoginTableAdapter
>            Dim dt As v2_communicationsDataSet.V2DataLoginDataTable
>            Dim row As v2_communicationsDataSet.V2DataLoginRow
>
>            dt = ta.GetData
>
>            row = dt.FindByUserNameID(str_username.Trim)
>            With row
>                .BeginEdit()
>                Debug.Print(.UserNameID & ", " & .Password)
>                .Password = texnewpassword.Text
>                Debug.Print(.UserNameID & ", " & .Password)
>                .EndEdit()
>            End With
>
>            ta.Update(dt)
>
>        Catch ex As Exception
>            MessageBox.Show(ex.Message, Application.ProductName,
> MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
>        End Try
>
>    End Sub
>
>
Author
7 May 2009 10:14 AM
C a r l o s A n t o n i o
It is a Typed Dataset.  That's why you do not see the SELECT statement in
the code  (if that's is what you mean). I get to the desired row by "row =
dt.FindByUserNameID(str_username.Trim)" line and the lines "
Debug.Print(.UserNameID & ", " & .Password) " correctly print the old and
new values respectively.  So I get it to make the changes in the DataRow.
But, I do not know why, changes are no reflected in the database and, as I
stated before, I do not get error messages either.

Thanks a lot,

Carlos




Show quoteHide quote
"Cor Ligthert[MVP]" <Notmyfirstn***@planet.nl> wrote in message
news:e2FovFtzJHA.480@TK2MSFTNGP06.phx.gbl...
> Carlos,
>
> I don't see new, deleted or changed data.
>
> Or I should misinterpret the method dt.GetData
>
> Cor
>
> "C a r l o s A n t o n i o" <carlvazpr¿arroba?yahoo.com> wrote in message
> news:eqc2ylrzJHA.2480@TK2MSFTNGP06.phx.gbl...
>> Sorry for the x-posting.  It's just I'm not sure which group this post is
>> related to.
>>
>> Well,  I have an Access 2007 database (also tried with Access 2003 with
>> no success) and I am creating an application for my programming class
>> (which is due this week) using VB2008.  I am using Typed Datasets.  The
>> thing is that I cannot do a simple thing as updating a record.  I do not
>> get error messages either.  I will post the code, if anyone could help
>> me, I will be very grateful.
>>
>> Thanks a lot for your help.
>>
>>    Private Sub update_new_user_password()
>>        Try
>>
>>
>>            'Connection String in My.Settings:
>>            'Provider=Microsoft.ACE.OLEDB.12.0;Data
>> Source="|DataDirectory|\DAL\Databases\v2 communications.accdb";Persist
>> Security Info=True
>>
>>            Dim ta As New
>> v2_communicationsDataSetTableAdapters.V2DataLoginTableAdapter
>>            Dim dt As v2_communicationsDataSet.V2DataLoginDataTable
>>            Dim row As v2_communicationsDataSet.V2DataLoginRow
>>
>>            dt = ta.GetData
>>
>>            row = dt.FindByUserNameID(str_username.Trim)
>>            With row
>>                .BeginEdit()
>>                Debug.Print(.UserNameID & ", " & .Password)
>>                .Password = texnewpassword.Text
>>                Debug.Print(.UserNameID & ", " & .Password)
>>                .EndEdit()
>>            End With
>>
>>            ta.Update(dt)
>>
>>        Catch ex As Exception
>>            MessageBox.Show(ex.Message, Application.ProductName,
>> MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
>>        End Try
>>
>>    End Sub
>>
>>
>
Author
7 May 2009 11:44 AM
Cor Ligthert[MVP]
Carlos

To update you have to change something.

A dataadapter does not affect non changed rows.

Cor

Show quoteHide quote
"C a r l o s A n t o n i o" <carlvazpr¿arroba?yahoo.com> wrote in message
news:%23ASfqyvzJHA.4800@TK2MSFTNGP06.phx.gbl...
> It is a Typed Dataset.  That's why you do not see the SELECT statement in
> the code  (if that's is what you mean). I get to the desired row by "row =
> dt.FindByUserNameID(str_username.Trim)" line and the lines "
> Debug.Print(.UserNameID & ", " & .Password) " correctly print the old and
> new values respectively.  So I get it to make the changes in the DataRow.
> But, I do not know why, changes are no reflected in the database and, as I
> stated before, I do not get error messages either.
>
> Thanks a lot,
>
> Carlos
>
>
>
>
> "Cor Ligthert[MVP]" <Notmyfirstn***@planet.nl> wrote in message
> news:e2FovFtzJHA.480@TK2MSFTNGP06.phx.gbl...
>> Carlos,
>>
>> I don't see new, deleted or changed data.
>>
>> Or I should misinterpret the method dt.GetData
>>
>> Cor
>>
>> "C a r l o s A n t o n i o" <carlvazpr¿arroba?yahoo.com> wrote in message
>> news:eqc2ylrzJHA.2480@TK2MSFTNGP06.phx.gbl...
>>> Sorry for the x-posting.  It's just I'm not sure which group this post
>>> is related to.
>>>
>>> Well,  I have an Access 2007 database (also tried with Access 2003 with
>>> no success) and I am creating an application for my programming class
>>> (which is due this week) using VB2008.  I am using Typed Datasets.  The
>>> thing is that I cannot do a simple thing as updating a record.  I do not
>>> get error messages either.  I will post the code, if anyone could help
>>> me, I will be very grateful.
>>>
>>> Thanks a lot for your help.
>>>
>>>    Private Sub update_new_user_password()
>>>        Try
>>>
>>>
>>>            'Connection String in My.Settings:
>>>            'Provider=Microsoft.ACE.OLEDB.12.0;Data
>>> Source="|DataDirectory|\DAL\Databases\v2 communications.accdb";Persist
>>> Security Info=True
>>>
>>>            Dim ta As New
>>> v2_communicationsDataSetTableAdapters.V2DataLoginTableAdapter
>>>            Dim dt As v2_communicationsDataSet.V2DataLoginDataTable
>>>            Dim row As v2_communicationsDataSet.V2DataLoginRow
>>>
>>>            dt = ta.GetData
>>>
>>>            row = dt.FindByUserNameID(str_username.Trim)
>>>            With row
>>>                .BeginEdit()
>>>                Debug.Print(.UserNameID & ", " & .Password)
>>>                .Password = texnewpassword.Text
>>>                Debug.Print(.UserNameID & ", " & .Password)
>>>                .EndEdit()
>>>            End With
>>>
>>>            ta.Update(dt)
>>>
>>>        Catch ex As Exception
>>>            MessageBox.Show(ex.Message, Application.ProductName,
>>> MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
>>>        End Try
>>>
>>>    End Sub
>>>
>>>
>>
>
>
Author
7 May 2009 11:59 AM
Armin Zingler
Cor Ligthert[MVP] wrote:
> Carlos
>
> To update you have to change something.

Isn't this the change?

            With row
                '...
                .Password = texnewpassword.Text
                '...
            end with


Armin
Author
7 May 2009 12:23 PM
C a r l o s A n t o n i o
Yes it is.


Show quoteHide quote
"Armin Zingler" <az.nospam@freenet.de> wrote in message
news:%23oLhQuwzJHA.5728@TK2MSFTNGP03.phx.gbl...
> Cor Ligthert[MVP] wrote:
>> Carlos
>>
>> To update you have to change something.
>
> Isn't this the change?
>
>            With row
>                '...
>                .Password = texnewpassword.Text
>                '...
>            end with
>
>
> Armin
>
Author
7 May 2009 2:23 PM
Cor Ligthert[MVP]
Carlos,

Sorry, I completely overlooked that.

Can you change it to this to narrow your code and try this, I don't really
not see anything

              Row.Password = "Whatever"

That BeginEdit and EndEdit are for a databinded control, I assume that you
did not do that, otherwise we know probably the problem.

Cor
Author
7 May 2009 3:25 PM
C a r l o s A n t o n i o
Changed the line to [.Password = "whatever"]   with same results.  Also,
eliminated BeginEdit and EndEdit methods and still not working.
Show quoteHide quote
:-S



"Cor Ligthert[MVP]" <Notmyfirstn***@planet.nl> wrote in message
news:%23Qwqc9xzJHA.5684@TK2MSFTNGP04.phx.gbl...
> Carlos,
>
> Sorry, I completely overlooked that.
>
> Can you change it to this to narrow your code and try this, I don't really
> not see anything
>
>              Row.Password = "Whatever"
>
> That BeginEdit and EndEdit are for a databinded control, I assume that you
> did not do that, otherwise we know probably the problem.
>
> Cor
>
>
>
Author
7 May 2009 3:42 PM
Armin Zingler
C a r l o s A n t o n i o wrote:
> Changed the line to [.Password = "whatever"]   with same results. Also,
> eliminated BeginEdit and EndEdit methods and still not working.
> :-S
>

What is row.rowstate directly after assigning the value?
What is the rowstate after executing ta.update?

If ta.update is a function, what is the return value?


Armin
Author
14 May 2009 7:54 PM
C a r l o s A n t o n i o
Hello all,

Thank you very much for your answers.  After a some sleepless nights dealing
with the problem, i noticed that the database was included in the project.
Whenever i executed the code, VS copied the database into the BIN folder and
doing its changes in the copy of the database, not the original.

In the database properties, i set it to "Copy if Newer".  That way i could
open the copy of the DB in the BIN filder and could verify the changes in
it.

Thank you very much for your help, guys.


Carlos



Show quoteHide quote
"Armin Zingler" <az.nospam@freenet.de> wrote in message
news:uSI%23mUzzJHA.1432@TK2MSFTNGP02.phx.gbl...
>C a r l o s A n t o n i o wrote:
>> Changed the line to [.Password = "whatever"]   with same results. Also,
>> eliminated BeginEdit and EndEdit methods and still not working.
>> :-S
>>
>
> What is row.rowstate directly after assigning the value?
> What is the rowstate after executing ta.update?
>
> If ta.update is a function, what is the return value?
>
>
> Armin
>
Author
14 May 2009 8:35 PM
Armin Zingler
C a r l o s A n t o n i o wrote:
> Hello all,
>
> Thank you very much for your answers.  After a some sleepless nights
> dealing with the problem, i noticed that the database was included in
> the project. Whenever i executed the code, VS copied the database
> into the BIN folder and doing its changes in the copy of the
> database, not the original.
>
> In the database properties, i set it to "Copy if Newer".  That way i
> could open the copy of the DB in the BIN filder and could verify the
> changes in it.
>
> Thank you very much for your help, guys.

Thanks for letting us know.


Armin