tobin46
asked on
Update Dataset and Database
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.D WS_Main)
Me.Con_DWS.Close()
Dim drDWS_Main as ds_DWSMain.DWS_MainRow
drDWS_Main = Ds_DWSMain1.DWS_Main.FindB ySlip_no(m e.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.
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.D
Me.Con_DWS.Close()
Dim drDWS_Main as ds_DWSMain.DWS_MainRow
drDWS_Main = Ds_DWSMain1.DWS_Main.FindB
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
Con_DWS.Close()
Yet, the update doesn't happen.
ASKER
Tried that it didn't work.
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
ASKER
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.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ds_DWSMain.AcceptChanges()