473,406 Members | 2,847 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

Saving changes to a database

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.tbl Coompany)
bChange = False
End If

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

End Sub

Any suggestiona dn help is greatly appreciated!!!!

--
Tony
May 30 '06 #1
7 1328
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:E9**********************************@microsof t.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.tbl Coompany)
bChange = False
End If

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

End Sub

Any suggestiona dn help is greatly appreciated!!!!

--
Tony

May 31 '06 #2
On Tue, 30 May 2006 15:06:01 -0700, Tony A.
<To***@discussions.microsoft.com> wrote:
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.tbl Coompany)
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
May 31 '06 #3
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:E9**********************************@microsof t.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.tbl Coompany)
bChange = False
End If

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

End Sub

Any suggestiona dn help is greatly appreciated!!!!

--
Tony


May 31 '06 #4
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:E9**********************************@microsof t.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.tbl Coompany)
bChange = False
End If

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

End Sub

Any suggestiona dn help is greatly appreciated!!!!

--
Tony


Jun 1 '06 #5
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:E9**********************************@microsof t.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.tbl Coompany)
> bChange = False
> End If
>
> Me.DisplayPosition() 'reset record location
> Me.setMaintenceButtons(True)
>
> End Sub
>
> Any suggestiona dn help is greatly appreciated!!!!
>
> --
> Tony

Jun 1 '06 #6
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:E9**********************************@microsof t.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.tbl Coompany)
> > bChange = False
> > End If
> >
> > Me.DisplayPosition() 'reset record location
> > Me.setMaintenceButtons(True)
> >
> > End Sub
> >
> > Any suggestiona dn help is greatly appreciated!!!!
> >
> > --
> > Tony
>
>
>

Jun 2 '06 #7
Thank you.
--
Tony
"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:E9**********************************@microsof t.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.tbl Coompany)
> > > bChange = False
> > > End If
> > >
> > > Me.DisplayPosition() 'reset record location
> > > Me.setMaintenceButtons(True)
> > >
> > > End Sub
> > >
> > > Any suggestiona dn help is greatly appreciated!!!!
> > >
> > > --
> > > Tony
> >
> >
> >

Jun 2 '06 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: John | last post by:
(access 2002) Anyone have any suggestions as to what may be causing access to not save form changes after I "tell" it to, exit database, then re-open later to discover the changes had not been...
2
by: manning_news | last post by:
Has anyone had a problem with Access 2003 not saving their coding? I've been using 2003 for a couple of months now and just this week noticed that some coding I'd done for a database was not there...
4
by: Jager | last post by:
Ok, I've got a program I am working on that is supposed to save all changes to the dataset to the actual database, but this doesn't seem to be working. I used the DataAdapter.Update(DataSet)...
6
by: SemiNoviceProgramer | last post by:
Dear friends I started a new project in Visual studio 2005, then I added a database connection using the wizard (access database) the problem that when I press the save button on the automatically...
4
by: Jonathan Wood | last post by:
Okay, I've normally avoided a lot of database stuff but I can see that'll be hard with .NET. I created an Access database and have successfully bound TextBoxes to fields within that database....
11
by: Kevin | last post by:
I've been searching forever for examples of saving data changes in a DataGridView. There's all kinds of examples, but none really show how to save changes. Someone please help me. I have a...
2
by: Matt | last post by:
I'm new to C#, so this really easy to answer for anyone that is adept at this... I'm having trouble saving data from my text boxes on a user form to my SQL database. Everything works fine while...
1
by: Allie | last post by:
Hi, all. This might be a silly question... but I am very new to programming in SQL so please bear with me :) So. I'm using MS SQL Server 2005 Management Studio Express. I have a table that...
0
by: gyap88 | last post by:
I'm using VB 2005 to create a simple application where authorised users can edit the database. Firstly, the database will be imported into a datatable and into a datagrid. Public Class...
27
by: RobG | last post by:
I was investigating a function to determine whether daylight saving was being observed on a particular date (given the platform's regional settings) and came across a suggestion at merlyn.com to...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.