Solved

Update Dataset and Database

Posted on 2007-03-29
8
165 Views
Last Modified: 2010-04-23
I'm  trying to update a dataset and its not working.  
The form has 4 different 'modes' that it opens in for different formatting reasons.  When the user loads the form in Edit Mode, the form loads and I open the connection and fill the data adapter then use the FindBy function to locate the record the user wants (code below):

Me.Con_DWS.Open()
      Da_Main.Fill(Ds_DWSMain1.DWS_Main)
Me.Con_DWS.Close()

Dim drDWS_Main as ds_DWSMain.DWS_MainRow
drDWS_Main = Ds_DWSMain1.DWS_Main.FindBySlip_no(me.txtSlip_no.text)

txtJob_num.text = drDWS_Main.job_no
txtSWO_num.text = drDWS_Main.swo_no
txtDate.text = drDWS_Main.job_date
txtLocation = drDWS_Main.job_site
txtContractor.text = drDWS_Main.contractor
txtdescription.text = drDWS_Main.job_desc

At this point I have the information in the textboxes based on what the user has entered in txtSlip_no.text.

The user can then edit some of the fields.  The user will then save the data and I run the following code:

Public Sub btnSave.....
Con_DWS.Open()
Dim drDWS_Main as ds_DWSMain.DWS_MainRow
drDWS_Main.job_no = txtJob_num.text
drDWS_Main.swo_no = txtSWO_num.text
drDWS_Main.job_date = txtDate.text
drDWS_Main.job_site = txtLocation
drDWS_Main.contractor = txtContractor.text
drDWS_Main.job_desc = txtdescription.text

Da_Main.Update(ds_DWSMain1.DWS_Main)
Con_DWS.Close()

Yet, the update doesn't happen.  
0
Comment
Question by:tobin46
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
8 Comments
 
LVL 7

Expert Comment

by:dctuck
ID: 18818730
I assume that ds_DWSMain is a DataSet, in which case, after the Da_Main.Update call, you need to have:

ds_DWSMain.AcceptChanges()
0
 
LVL 1

Author Comment

by:tobin46
ID: 18819004
Tried that it didn't work.  
0
 
LVL 7

Expert Comment

by:dctuck
ID: 18821990
You shouldn't actually need to open your connections for datasets and dataadapters, as it should do that for you automatically. Not sure if that makes any difference, though
0
 
LVL 1

Author Comment

by:tobin46
ID: 18833017
I think you are right.  The textboxes aren't bound to the dataset though.  If they were bound to the dataset, it would automatically update if there are changes.  

0
 
LVL 7

Accepted Solution

by:
dctuck earned 500 total points
ID: 18833055
Just realised - you haven't actually added the row to the dataset.

ds_DWSMain.DWS_Main.AddDWS_MainRow(drDWS_Main)

before Update / AcceptChanges commands
0

Featured Post

PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Article by: Kraeven
Introduction Remote Share is a simple remote sharing tool, enabling you to see, add and remove remote or local shares. The application is written in VB.NET targeting the .NET framework 2.0. The source code and the compiled programs have been in…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

710 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question