Results 1 to 8 of 8

Thread: Dataset does not update database

Threaded View

  1. #1

    Thread Starter
    New Member
    Join Date
    May 2008
    Posts
    6

    Unhappy Dataset does not update database

    Using VB.net 2.0

    I have created a form in to which i have dragged a details view of a table from a database.



    When i add a new client and save, close the program and open it, the new client is present, if i close VS2005 and open the DB there is no new record, open VS2005 again and the new client record has disappeared.

    I think the data set is not updating the database. I have the database properties set to copy if newer.

    I have tried using the built in toolstrip to the same outcome.

    The code for my form:

    Code:
    
    Public Class frmClient
    
        Private Sub frmClient_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
            'TODO: This line of code loads data into the 'DsGT2000New.tblClient' table. You can move, or remove it, as needed.
            Me.TblClientTableAdapter.Fill(Me.DsGT2000New.tblClient)
    
            'Check if User name = Admin if so enable the delete button
            If frmPass.txtUserName.Text = "Admin" Then
                btnDel.Enabled = True
            End If
    
        End Sub
        
    
        Private Sub btnExit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnExit.Click
            'close program
            Me.Close()
            End
        End Sub
                   
     
        Private Sub btnPrev_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnPrev.Click
            Me.TblClientBindingSource.MovePrevious()
        End Sub
        '-----------------------------------------------------------------------------------------------------------------------------
        '-----------------------------------------------------------------------------------------------------------------------------
        'Procedure              :btnNext                 
        'Project                :GT2000Project
        'Version                :1.0 
        'Date                   :18/04/2008
        'Author                 :Craig Hendley
        'Description            :button to take the user to the next record
        '                       :
        '-----------------------------------------------------------------------------------------------------------------------------
        '-----------------------------------------------------------------------------------------------------------------------------
        Private Sub btnNext_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnNext.Click
            Me.TblClientBindingSource.MoveNext()
        End Sub
        '-----------------------------------------------------------------------------------------------------------------------------
        '-----------------------------------------------------------------------------------------------------------------------------
        'Procedure              :btnAddNew                 
        'Project                :GT2000Project
        'Version                :1.0 
        'Date                   :18/04/2008
        'Author                 :Craig Hendley
        'Description            :button to start a blank record for new input
        '                       :
        '-----------------------------------------------------------------------------------------------------------------------------
        '-----------------------------------------------------------------------------------------------------------------------------
        Private Sub btnAddNew_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnAddNew.Click
            Me.TblClientBindingSource.AddNew()
        End Sub
        '-----------------------------------------------------------------------------------------------------------------------------
        '-----------------------------------------------------------------------------------------------------------------------------
        'Procedure              :btnDel                 
        'Project                :GT2000Project
        'Version                :1.0 
        'Date                   :18/04/2008
        'Author                 :Craig Hendley
        'Description            :button to delete record
        '                       :
        '-----------------------------------------------------------------------------------------------------------------------------
        '-----------------------------------------------------------------------------------------------------------------------------
        Private Sub btnDel_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnDel.Click
            MessageBox.Show("Are You Sure You Wish To Delete This Record?", "Confirm ", MessageBoxButtons.OKCancel, MessageBoxIcon.Question)
    
        End Sub
        '-----------------------------------------------------------------------------------------------------------------------------
        '-----------------------------------------------------------------------------------------------------------------------------
        'Procedure              :CIDTextBox_KeyPress                 
        'Project                :GT2000Project
        'Version                :1.0 
        'Date                   :18/04/2008
        'Author                 :Craig Hendley
        'Description            :Limits allowed character presses to "C", Numeric values, tab and backspace
        '                       :
        '-----------------------------------------------------------------------------------------------------------------------------
        '-----------------------------------------------------------------------------------------------------------------------------
        Private Sub CIDTextBox_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles CIDTextBox.KeyPress
            If (e.KeyChar <> "C") Then
                If (e.KeyChar < "0" Or e.KeyChar > "9") Then
                    If (AscW(e.KeyChar) <> AscW(ControlChars.Back) AndAlso AscW(e.KeyChar) <> AscW(ControlChars.Tab)) Then
                        e.Handled = True
                    End If
                End If
            End If
        End Sub
        '-----------------------------------------------------------------------------------------------------------------------------
        '-----------------------------------------------------------------------------------------------------------------------------
        'Procedure              :DOBDateTimePicker_ValueChanged                 
        'Project                :GT2000Project
        'Version                :1.0 
        'Date                   :18/04/2008
        'Author                 :Craig Hendley
        'Description            :Limits allowed character presses to "C", Numeric values, tab and backspace
        '                       :
        '-----------------------------------------------------------------------------------------------------------------------------
        '-----------------------------------------------------------------------------------------------------------------------------
    
        Private Sub DOBDateTimePicker_ValueChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles DOBDateTimePicker.ValueChanged
            Dim d As Date = Date.Now
            d = New Date(d.Year - 18, d.Month, d.Day)
    
    
            If DOBDateTimePicker.Value <= d Then
                Me.err1.SetError(DOBDateTimePicker, "")
    
            Else
    
                Me.err1.SetError(DOBDateTimePicker, "Must Be over 18!")
                Me.DOBDateTimePicker.Focus()
    
            End If
        End Sub
        '-----------------------------------------------------------------------------------------------------------------------------
        '-----------------------------------------------------------------------------------------------------------------------------
        'Procedure              :btnSav                
        'Project                :GT2000Project
        'Version                :1.0 
        'Date                   :18/04/2008
        'Author                 :Craig Hendley
        'Description            :button to save date in the dataset to the database
        '                       :
        '-----------------------------------------------------------------------------------------------------------------------------
        '-----------------------------------------------------------------------------------------------------------------------------
        Private Sub btnSav_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSav.Click
            Me.Validate()
            Me.TblClientBindingSource.EndEdit()
            Me.TblClientTableAdapter.Update(Me.DsGT2000New.tblClient)
        End Sub
    End Class



    This is really worrying me, i need to sort it out ASAP so anything you guys can advise me on would be much appreciated
    Last edited by ABOU; May 2nd, 2008 at 01:44 PM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width