Home All Groups Group Topic Archive Search About

Saving changes to a database

Author
30 May 2006 10:06 PM
Tony A.
I'm working on an application using VB .Net 2005 and MS Access 2003 for the
database.  The table I'm trying to update has a key field.  When I click the
Save Button the update seems to work in the dataset, but the database is not
updated.  The code I'm using for the btnSave is:

Private Sub btnSave_Click(ByVal sender As System.Object, _
    ByVal e As System.EventArgs) Handles btnSave.Click

        'saves adds and edits to database
        If bChange = False Then
            MsgBox("Nothing To Save", MsgBoxStyle.OkOnly, "Test!!!!")
        Else
            Me.Validate()
            Me.TblCompanyBindingSource.EndEdit()
            Me.TblCompanyTableAdapter.Update(Me.DsCompData.tblCoompany)
            bChange = False
        End If

        Me.DisplayPosition()    'reset record location
        Me.setMaintenceButtons(True)

    End Sub

Any suggestiona dn help is greatly appreciated!!!!

--
Tony

Author
31 May 2006 5:31 AM
Cor Ligthert [MVP]
Tony,

Are you sure that this is your code. Because it seems if you are using two
different tables.

Cor

Show quoteHide quote
"Tony A." <To***@discussions.microsoft.com> schreef in bericht
news:E907AFE6-BAE3-4995-92A9-6E330CDC7819@microsoft.com...
> I'm working on an application using VB .Net 2005 and MS Access 2003 for
> the
> database.  The table I'm trying to update has a key field.  When I click
> the
> Save Button the update seems to work in the dataset, but the database is
> not
> updated.  The code I'm using for the btnSave is:
>
> Private Sub btnSave_Click(ByVal sender As System.Object, _
>    ByVal e As System.EventArgs) Handles btnSave.Click
>
>        'saves adds and edits to database
>        If bChange = False Then
>            MsgBox("Nothing To Save", MsgBoxStyle.OkOnly, "Test!!!!")
>        Else
>            Me.Validate()
>            Me.TblCompanyBindingSource.EndEdit()
>            Me.TblCompanyTableAdapter.Update(Me.DsCompData.tblCoompany)
>            bChange = False
>        End If
>
>        Me.DisplayPosition()    'reset record location
>        Me.setMaintenceButtons(True)
>
>    End Sub
>
> Any suggestiona dn help is greatly appreciated!!!!
>
> --
> Tony
Author
31 May 2006 4:33 PM
Tony A.
I see where tblCoompany was misspelled. Should have been tblCompany.  It is
correct in the application.  Thanks.  Other suggestions??
--
Tony


Show quoteHide quote
"Cor Ligthert [MVP]" wrote:

> Tony,
>
> Are you sure that this is your code. Because it seems if you are using two
> different tables.
>
> Cor
>
> "Tony A." <To***@discussions.microsoft.com> schreef in bericht
> news:E907AFE6-BAE3-4995-92A9-6E330CDC7819@microsoft.com...
> > I'm working on an application using VB .Net 2005 and MS Access 2003 for
> > the
> > database.  The table I'm trying to update has a key field.  When I click
> > the
> > Save Button the update seems to work in the dataset, but the database is
> > not
> > updated.  The code I'm using for the btnSave is:
> >
> > Private Sub btnSave_Click(ByVal sender As System.Object, _
> >    ByVal e As System.EventArgs) Handles btnSave.Click
> >
> >        'saves adds and edits to database
> >        If bChange = False Then
> >            MsgBox("Nothing To Save", MsgBoxStyle.OkOnly, "Test!!!!")
> >        Else
> >            Me.Validate()
> >            Me.TblCompanyBindingSource.EndEdit()
> >            Me.TblCompanyTableAdapter.Update(Me.DsCompData.tblCoompany)
> >            bChange = False
> >        End If
> >
> >        Me.DisplayPosition()    'reset record location
> >        Me.setMaintenceButtons(True)
> >
> >    End Sub
> >
> > Any suggestiona dn help is greatly appreciated!!!!
> >
> > --
> > Tony
>
>
>
Author
1 Jun 2006 2:59 AM
ewok66
What is bchange and when is it getting changed?  Are you sure the
tableadapter is firing the update event?
--
--ewok
MCSA+M,MCSE, MCSD, MCDBA,MCITP


Show quoteHide quote
"Tony A." wrote:

> I see where tblCoompany was misspelled. Should have been tblCompany.  It is
> correct in the application.  Thanks.  Other suggestions??
> --
> Tony
>
>
> "Cor Ligthert [MVP]" wrote:
>
> > Tony,
> >
> > Are you sure that this is your code. Because it seems if you are using two
> > different tables.
> >
> > Cor
> >
> > "Tony A." <To***@discussions.microsoft.com> schreef in bericht
> > news:E907AFE6-BAE3-4995-92A9-6E330CDC7819@microsoft.com...
> > > I'm working on an application using VB .Net 2005 and MS Access 2003 for
> > > the
> > > database.  The table I'm trying to update has a key field.  When I click
> > > the
> > > Save Button the update seems to work in the dataset, but the database is
> > > not
> > > updated.  The code I'm using for the btnSave is:
> > >
> > > Private Sub btnSave_Click(ByVal sender As System.Object, _
> > >    ByVal e As System.EventArgs) Handles btnSave.Click
> > >
> > >        'saves adds and edits to database
> > >        If bChange = False Then
> > >            MsgBox("Nothing To Save", MsgBoxStyle.OkOnly, "Test!!!!")
> > >        Else
> > >            Me.Validate()
> > >            Me.TblCompanyBindingSource.EndEdit()
> > >            Me.TblCompanyTableAdapter.Update(Me.DsCompData.tblCoompany)
> > >            bChange = False
> > >        End If
> > >
> > >        Me.DisplayPosition()    'reset record location
> > >        Me.setMaintenceButtons(True)
> > >
> > >    End Sub
> > >
> > > Any suggestiona dn help is greatly appreciated!!!!
> > >
> > > --
> > > Tony
> >
> >
> >
Author
1 Jun 2006 7:08 PM
Tony A.
I have a procedure that checks to see if the value in any of the text boxes
or combo box has changed = bchange

The program crashes at the TableAdapter.Update line.  This error appears:

Update requires a valid UpdateCommand when passed DataRow collection with
modified rows.


--
Tony


Show quoteHide quote
"ewok66" wrote:

> What is bchange and when is it getting changed?  Are you sure the
> tableadapter is firing the update event?
> --
> --ewok
> MCSA+M,MCSE, MCSD, MCDBA,MCITP
>
>
> "Tony A." wrote:
>
> > I see where tblCoompany was misspelled. Should have been tblCompany.  It is
> > correct in the application.  Thanks.  Other suggestions??
> > --
> > Tony
> >
> >
> > "Cor Ligthert [MVP]" wrote:
> >
> > > Tony,
> > >
> > > Are you sure that this is your code. Because it seems if you are using two
> > > different tables.
> > >
> > > Cor
> > >
> > > "Tony A." <To***@discussions.microsoft.com> schreef in bericht
> > > news:E907AFE6-BAE3-4995-92A9-6E330CDC7819@microsoft.com...
> > > > I'm working on an application using VB .Net 2005 and MS Access 2003 for
> > > > the
> > > > database.  The table I'm trying to update has a key field.  When I click
> > > > the
> > > > Save Button the update seems to work in the dataset, but the database is
> > > > not
> > > > updated.  The code I'm using for the btnSave is:
> > > >
> > > > Private Sub btnSave_Click(ByVal sender As System.Object, _
> > > >    ByVal e As System.EventArgs) Handles btnSave.Click
> > > >
> > > >        'saves adds and edits to database
> > > >        If bChange = False Then
> > > >            MsgBox("Nothing To Save", MsgBoxStyle.OkOnly, "Test!!!!")
> > > >        Else
> > > >            Me.Validate()
> > > >            Me.TblCompanyBindingSource.EndEdit()
> > > >            Me.TblCompanyTableAdapter.Update(Me.DsCompData.tblCoompany)
> > > >            bChange = False
> > > >        End If
> > > >
> > > >        Me.DisplayPosition()    'reset record location
> > > >        Me.setMaintenceButtons(True)
> > > >
> > > >    End Sub
> > > >
> > > > Any suggestiona dn help is greatly appreciated!!!!
> > > >
> > > > --
> > > > Tony
> > >
> > >
> > >
Author
2 Jun 2006 1:11 AM
ewok66
Sounds like you need an update statement - did you remove it at some point
from your data adapter?  If you use a wizard to automatically add one, ensure
part of the update statement doesn't try and update your key field.
--
--ewok
MCSA+M,MCSE, MCSD, MCDBA,MCITP


Show quoteHide quote
"Tony A." wrote:

> I have a procedure that checks to see if the value in any of the text boxes
> or combo box has changed = bchange
>
> The program crashes at the TableAdapter.Update line.  This error appears:
>
> Update requires a valid UpdateCommand when passed DataRow collection with
> modified rows.
>
>
> --
> Tony
>
>
> "ewok66" wrote:
>
> > What is bchange and when is it getting changed?  Are you sure the
> > tableadapter is firing the update event?
> > --
> > --ewok
> > MCSA+M,MCSE, MCSD, MCDBA,MCITP
> >
> >
> > "Tony A." wrote:
> >
> > > I see where tblCoompany was misspelled. Should have been tblCompany.  It is
> > > correct in the application.  Thanks.  Other suggestions??
> > > --
> > > Tony
> > >
> > >
> > > "Cor Ligthert [MVP]" wrote:
> > >
> > > > Tony,
> > > >
> > > > Are you sure that this is your code. Because it seems if you are using two
> > > > different tables.
> > > >
> > > > Cor
> > > >
> > > > "Tony A." <To***@discussions.microsoft.com> schreef in bericht
> > > > news:E907AFE6-BAE3-4995-92A9-6E330CDC7819@microsoft.com...
> > > > > I'm working on an application using VB .Net 2005 and MS Access 2003 for
> > > > > the
> > > > > database.  The table I'm trying to update has a key field.  When I click
> > > > > the
> > > > > Save Button the update seems to work in the dataset, but the database is
> > > > > not
> > > > > updated.  The code I'm using for the btnSave is:
> > > > >
> > > > > Private Sub btnSave_Click(ByVal sender As System.Object, _
> > > > >    ByVal e As System.EventArgs) Handles btnSave.Click
> > > > >
> > > > >        'saves adds and edits to database
> > > > >        If bChange = False Then
> > > > >            MsgBox("Nothing To Save", MsgBoxStyle.OkOnly, "Test!!!!")
> > > > >        Else
> > > > >            Me.Validate()
> > > > >            Me.TblCompanyBindingSource.EndEdit()
> > > > >            Me.TblCompanyTableAdapter.Update(Me.DsCompData.tblCoompany)
> > > > >            bChange = False
> > > > >        End If
> > > > >
> > > > >        Me.DisplayPosition()    'reset record location
> > > > >        Me.setMaintenceButtons(True)
> > > > >
> > > > >    End Sub
> > > > >
> > > > > Any suggestiona dn help is greatly appreciated!!!!
> > > > >
> > > > > --
> > > > > Tony
> > > >
> > > >
> > > >
Author
2 Jun 2006 3:11 PM
Tony A.
Thank you.
--
Tony


Show quoteHide quote
"ewok66" wrote:

> Sounds like you need an update statement - did you remove it at some point
> from your data adapter?  If you use a wizard to automatically add one, ensure
> part of the update statement doesn't try and update your key field.
> --
> --ewok
> MCSA+M,MCSE, MCSD, MCDBA,MCITP
>
>
> "Tony A." wrote:
>
> > I have a procedure that checks to see if the value in any of the text boxes
> > or combo box has changed = bchange
> >
> > The program crashes at the TableAdapter.Update line.  This error appears:
> >
> > Update requires a valid UpdateCommand when passed DataRow collection with
> > modified rows.
> >
> >
> > --
> > Tony
> >
> >
> > "ewok66" wrote:
> >
> > > What is bchange and when is it getting changed?  Are you sure the
> > > tableadapter is firing the update event?
> > > --
> > > --ewok
> > > MCSA+M,MCSE, MCSD, MCDBA,MCITP
> > >
> > >
> > > "Tony A." wrote:
> > >
> > > > I see where tblCoompany was misspelled. Should have been tblCompany.  It is
> > > > correct in the application.  Thanks.  Other suggestions??
> > > > --
> > > > Tony
> > > >
> > > >
> > > > "Cor Ligthert [MVP]" wrote:
> > > >
> > > > > Tony,
> > > > >
> > > > > Are you sure that this is your code. Because it seems if you are using two
> > > > > different tables.
> > > > >
> > > > > Cor
> > > > >
> > > > > "Tony A." <To***@discussions.microsoft.com> schreef in bericht
> > > > > news:E907AFE6-BAE3-4995-92A9-6E330CDC7819@microsoft.com...
> > > > > > I'm working on an application using VB .Net 2005 and MS Access 2003 for
> > > > > > the
> > > > > > database.  The table I'm trying to update has a key field.  When I click
> > > > > > the
> > > > > > Save Button the update seems to work in the dataset, but the database is
> > > > > > not
> > > > > > updated.  The code I'm using for the btnSave is:
> > > > > >
> > > > > > Private Sub btnSave_Click(ByVal sender As System.Object, _
> > > > > >    ByVal e As System.EventArgs) Handles btnSave.Click
> > > > > >
> > > > > >        'saves adds and edits to database
> > > > > >        If bChange = False Then
> > > > > >            MsgBox("Nothing To Save", MsgBoxStyle.OkOnly, "Test!!!!")
> > > > > >        Else
> > > > > >            Me.Validate()
> > > > > >            Me.TblCompanyBindingSource.EndEdit()
> > > > > >            Me.TblCompanyTableAdapter.Update(Me.DsCompData.tblCoompany)
> > > > > >            bChange = False
> > > > > >        End If
> > > > > >
> > > > > >        Me.DisplayPosition()    'reset record location
> > > > > >        Me.setMaintenceButtons(True)
> > > > > >
> > > > > >    End Sub
> > > > > >
> > > > > > Any suggestiona dn help is greatly appreciated!!!!
> > > > > >
> > > > > > --
> > > > > > Tony
> > > > >
> > > > >
> > > > >
Author
31 May 2006 8:01 AM
gene kelley
On Tue, 30 May 2006 15:06:01 -0700, Tony A.
<To***@discussions.microsoft.com> wrote:

Show quoteHide quote
>I'm working on an application using VB .Net 2005 and MS Access 2003 for the
>database.  The table I'm trying to update has a key field.  When I click the
>Save Button the update seems to work in the dataset, but the database is not
>updated.  The code I'm using for the btnSave is:
>
>Private Sub btnSave_Click(ByVal sender As System.Object, _
>    ByVal e As System.EventArgs) Handles btnSave.Click
>
>        'saves adds and edits to database
>        If bChange = False Then
>            MsgBox("Nothing To Save", MsgBoxStyle.OkOnly, "Test!!!!")
>        Else
>            Me.Validate()
>            Me.TblCompanyBindingSource.EndEdit()
>            Me.TblCompanyTableAdapter.Update(Me.DsCompData.tblCoompany)
>            bChange = False
>        End If
>
>        Me.DisplayPosition()    'reset record location
>        Me.setMaintenceButtons(True)
>
>    End Sub
>
>Any suggestiona dn help is greatly appreciated!!!!

In debug mode? Select the DB and change the "Copy to Output
Dirirectory" property to something else if it is currently set to
'Copy Always'

Gene