Update database question
Update database question
Update database question
Update database question
Update database question
Update database question Update database question Update database question Update database question Update database question Update database question Update database question Update database question
Update database question Update database question
Update database question
Go Back  Xtreme Visual Basic Talk > > > Update database question


Reply
 
Thread Tools Display Modes
  #1  
Old 07-31-2015, 04:52 AM
pjstreetglide pjstreetglide is offline
Newcomer
 
Join Date: Jul 2015
Posts: 1
Default Update database question


Hi all, I'm new to the forum. I'm just learning to do database programing and I'm having a problem with updating my table in my database. the changes work fine in the dataset but does not show up in the database. Here is my code...
Code:
        With ItemCheckGrid
            ColSel = .CurrentCell.ColumnIndex
            RowDex = .CurrentCell.RowIndex
            Select Case True
                Case rbOrdered.Checked
                    .Rows(RowDex).Cells(ColSel).Value = "O"
                Case rbSched.Checked
                    .Rows(RowDex).Cells(ColSel).Value = "Sch"
                Case rbIP.Checked
                    .Rows(RowDex).Cells(ColSel).Value = "IP"
                Case rbDNA.Checked
                    .Rows(RowDex).Cells(ColSel).Value = "NA"
                Case rbClear.Checked
                    .Rows(RowDex).Cells(ColSel).Value = ""
                Case rbComplete.Checked
                    .Rows(RowDex).Cells(ColSel).Value = "x"
            End Select

            Try
                Dim cb As New OleDb.OleDbCommandBuilder(da)
                If ds.Tables("Trackerds").Rows(RowDex).Item(2) = FixedGrid.Rows(RowDex).Cells(1).Value Then

                    ds.Tables("Trackerds").Rows(RowDex).Item(1) = FixedGrid.Rows(RowDex).Cells(0).Value
                    ds.Tables("Trackerds").Rows(RowDex).Item(2) = FixedGrid.Rows(RowDex).Cells(1).Value
                    ds.Tables("Trackerds").Rows(RowDex).Item(3) = FixedGrid.Rows(RowDex).Cells(2).Value
                    ds.Tables("Trackerds").Rows(RowDex).Item(ColSel + 1) = .Rows(RowDex).Cells(ColSel).Value

                    ds.AcceptChanges()
                    da.Update(ds, "Trackerds")
                    MsgBox(ds.Tables("Trackerds").Rows(RowDex).Item(ColSel + 1))
                    MsgBox("Entry Saved")
                End If
            Catch exceptionObject As Exception
                MessageBox.Show(exceptionObject.Message)
            Finally

            End Try

        End With
Reply With Quote
  #2  
Old 08-11-2015, 05:19 PM
pschulz pschulz is offline
Newcomer
 
Join Date: Jul 2015
Posts: 6
Default

just by watching the code, might be possible, might be, that:
The last sql-statemant, given to the DataAdapter, its not the one which is needed at this point.
The commanduilder care about the last sql-statment, given to the DataAdapter.
Reply With Quote
  #3  
Old 08-11-2015, 05:58 PM
PlausiblyDamp's Avatar
PlausiblyDampUpdate database question PlausiblyDamp is offline
Ultimate Contributor

Forum Leader
* Expert *
 
Join Date: Nov 2003
Location: Newport, Wales
Posts: 2,058
Default

Been a while since I have done anything with DataSets but IIRC the lines
Code:
ds.AcceptChanges()
da.Update(ds, "Trackerds")
Need to be swapped i.e. change them to
Code:
da.Update(ds, "Trackerds")
ds.AcceptChanges()
Calling .AcceptChanges on a DataSet marks all modified rows as being Unchanged, this means when you call .Update on the DataAdapter it doesn't see any changes to propagate to the database.
__________________
Intellectuals solve problems; geniuses prevent them.
-- Albert Einstein

Posting Guidelines Forum Rules Use the code tags
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
Update database question
Update database question
Update database question Update database question
Update database question
Update database question
Update database question Update database question Update database question Update database question Update database question Update database question Update database question
Update database question
Update database question
 
Update database question
Update database question
 
-->