473,805 Members | 1,978 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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(B yVal sender As System.Object, _
ByVal e As System.EventArg s) Handles btnSave.Click

'saves adds and edits to database
If bChange = False Then
MsgBox("Nothing To Save", MsgBoxStyle.OkO nly, "Test!!!!")
Else
Me.Validate()
Me.TblCompanyBi ndingSource.End Edit()
Me.TblCompanyTa bleAdapter.Upda te(Me.DsCompDat a.tblCoompany)
bChange = False
End If

Me.DisplayPosit ion() 'reset record location
Me.setMaintence Buttons(True)

End Sub

Any suggestiona dn help is greatly appreciated!!!!

--
Tony
May 30 '06 #1
7 1363
Tony,

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

Cor

"Tony A." <To***@discussi ons.microsoft.c om> schreef in bericht
news:E9******** *************** ***********@mic rosoft.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(B yVal sender As System.Object, _
ByVal e As System.EventArg s) Handles btnSave.Click

'saves adds and edits to database
If bChange = False Then
MsgBox("Nothing To Save", MsgBoxStyle.OkO nly, "Test!!!!")
Else
Me.Validate()
Me.TblCompanyBi ndingSource.End Edit()
Me.TblCompanyTa bleAdapter.Upda te(Me.DsCompDat a.tblCoompany)
bChange = False
End If

Me.DisplayPosit ion() 'reset record location
Me.setMaintence Buttons(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***@discussi ons.microsoft.c om> 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(B yVal sender As System.Object, _
ByVal e As System.EventArg s) Handles btnSave.Click

'saves adds and edits to database
If bChange = False Then
MsgBox("Nothing To Save", MsgBoxStyle.OkO nly, "Test!!!!")
Else
Me.Validate()
Me.TblCompanyBi ndingSource.End Edit()
Me.TblCompanyTa bleAdapter.Upda te(Me.DsCompDat a.tblCoompany)
bChange = False
End If

Me.DisplayPosit ion() 'reset record location
Me.setMaintence Buttons(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***@discussi ons.microsoft.c om> schreef in bericht
news:E9******** *************** ***********@mic rosoft.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(B yVal sender As System.Object, _
ByVal e As System.EventArg s) Handles btnSave.Click

'saves adds and edits to database
If bChange = False Then
MsgBox("Nothing To Save", MsgBoxStyle.OkO nly, "Test!!!!")
Else
Me.Validate()
Me.TblCompanyBi ndingSource.End Edit()
Me.TblCompanyTa bleAdapter.Upda te(Me.DsCompDat a.tblCoompany)
bChange = False
End If

Me.DisplayPosit ion() 'reset record location
Me.setMaintence Buttons(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***@discussi ons.microsoft.c om> schreef in bericht
news:E9******** *************** ***********@mic rosoft.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(B yVal sender As System.Object, _
ByVal e As System.EventArg s) Handles btnSave.Click

'saves adds and edits to database
If bChange = False Then
MsgBox("Nothing To Save", MsgBoxStyle.OkO nly, "Test!!!!")
Else
Me.Validate()
Me.TblCompanyBi ndingSource.End Edit()
Me.TblCompanyTa bleAdapter.Upda te(Me.DsCompDat a.tblCoompany)
bChange = False
End If

Me.DisplayPosit ion() 'reset record location
Me.setMaintence Buttons(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.Up date 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***@discussi ons.microsoft.c om> schreef in bericht
news:E9******** *************** ***********@mic rosoft.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(B yVal sender As System.Object, _
> ByVal e As System.EventArg s) Handles btnSave.Click
>
> 'saves adds and edits to database
> If bChange = False Then
> MsgBox("Nothing To Save", MsgBoxStyle.OkO nly, "Test!!!!")
> Else
> Me.Validate()
> Me.TblCompanyBi ndingSource.End Edit()
> Me.TblCompanyTa bleAdapter.Upda te(Me.DsCompDat a.tblCoompany)
> bChange = False
> End If
>
> Me.DisplayPosit ion() 'reset record location
> Me.setMaintence Buttons(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.Up date 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***@discussi ons.microsoft.c om> schreef in bericht
> news:E9******** *************** ***********@mic rosoft.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(B yVal sender As System.Object, _
> > ByVal e As System.EventArg s) Handles btnSave.Click
> >
> > 'saves adds and edits to database
> > If bChange = False Then
> > MsgBox("Nothing To Save", MsgBoxStyle.OkO nly, "Test!!!!")
> > Else
> > Me.Validate()
> > Me.TblCompanyBi ndingSource.End Edit()
> > Me.TblCompanyTa bleAdapter.Upda te(Me.DsCompDat a.tblCoompany)
> > bChange = False
> > End If
> >
> > Me.DisplayPosit ion() 'reset record location
> > Me.setMaintence Buttons(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.Up date 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***@discussi ons.microsoft.c om> schreef in bericht
> > news:E9******** *************** ***********@mic rosoft.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(B yVal sender As System.Object, _
> > > ByVal e As System.EventArg s) Handles btnSave.Click
> > >
> > > 'saves adds and edits to database
> > > If bChange = False Then
> > > MsgBox("Nothing To Save", MsgBoxStyle.OkO nly, "Test!!!!")
> > > Else
> > > Me.Validate()
> > > Me.TblCompanyBi ndingSource.End Edit()
> > > Me.TblCompanyTa bleAdapter.Upda te(Me.DsCompDat a.tblCoompany)
> > > bChange = False
> > > End If
> > >
> > > Me.DisplayPosit ion() 'reset record location
> > > Me.setMaintence Buttons(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
5649
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 saved (or somehow reverted). BUT, new form module code is saved. Example: created txtTitle control on form. Create AfterUpdate event code for txtTitle. Save form. Close database. Later...Open database, open form, txtTitle not there but its event...
2
1830
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 anymore. I reentered it and didn't have any problems for a couple of days. Today I entered some coding, saved it, opened another database, and when I opened my original database again, the coding I had entered was missing. Access 2000 always...
4
1053
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) method, but that doesn't save the changes to my actual database. How can I go about updating the actual database to save changes? Please help, Jager
6
1456
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 generated toolbar nothing saved to my database file, so each time I restarted the project I found the original dat unmodified what code should I add to the wizard-generated code to let the original database file updated permanently thanks in...
4
2488
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. I've also found the navagation toolbar, which seems pretty cool. Everything seems to work except when I quit and restart the app, all the new data is gone.
11
27325
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 Windows Forms program with a DataGridView and a BindingSource added to a form. Here is the code I'm using to populate the grid: Dim CRClassesTableAdapter As SqlDataAdapter Dim CRClassesTable As New DataTable()
2
1252
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 in debug mode, the data is saved and reflcted like it shoul be, but once I exit debug mode, all the changes are lost when I reopen the app in debug mode again? I saw the answer to this problem in a video but cannot find the video again? I tried...
1
2039
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 was created via an existing .sql file. Included were a bunch of stored procedures. I went in to re-format these procedures. (They were written in haste by another programmer. It is my task to go back and improve their readabilities.) However, I am...
0
1057
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 Databaseupdatting Dim dt As New DataTable() Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load dt.Clear() Dim SQLCon As New SqlClient.SqlConnection("Data...
27
6916
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 test the time zone offset on a variety of dates to see if it changes. Based on that, I developed the following checkDST() function which, as far as I can tell, should be sufficient. It checks either the date passed to it or the current date with...
0
9716
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10104
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7645
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6875
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5541
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5677
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4317
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3843
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3007
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.