数据库连接不是永久保存

时间:2015-03-16 15:47:32

标签: sql database vb.net connection

我正在使用visual basic express 2010,我已经连接到我制作的数据库。当我使用该程序时,第一手似乎没有任何错误我可以看到我使用该程序放入我的数据库的数据,数据也在我的数据库本身,但当我关闭visual basic并查看我的数据库几天后所有我之前的数据已经消失了,所以说实话,我的数据不会永久保存。现在我知道这是因为我使用的数据集是一个脱机数据库连接。现在我的问题是我可以更改我的代码,以便当我点击“保存”时,我的数据实际上保存在我的数据库中并且几天内不会消失吗?我的代码(有些东西在荷兰抱歉):

Public Class KlantToevoegen

Private Sub KlantBindingNavigatorSaveItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles KlantBindingNavigatorSaveItem.Click

    If TbGemeente.Text = ""
    Or TbPostcode.Text = ""
    Or TbAdres.Text = ""
    Or TbVoornaam.Text = ""
    Or TbNaam.Text = ""
  Then
    MsgBox("Update failed!")
Else
    Me.Validate()
    Me.KlantBindingSource.EndEdit()
    Me.TableAdapterManager.UpdateAll(Me.PowerShotKassaBonDataSet)
    MsgBox("Update successful")
End If
End Sub

Private Sub KlantToevoegen_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

Me.KlantTableAdapter.Fill(Me.PowerShotKassaBonDataSet.Klant)
End Sub

Private Sub TbGemeente_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TbGemeente.TextChanged

    If TbGemeente.Text = ""
Then
    Me.ErrInvullen.SetError(Me.TbGemeente, " Geef de gemeente in. ")
Else
    Me.ErrInvullen.SetError(Me.TbGemeente, "")
End If
End Sub

Private Sub TbPostcode_TextChanged(sender As System.Object, e As System.EventArgs) Handles TbPostcode.TextChanged

    If Not IsNumeric(Me.TbPostcode.Text) Then
    Me.ErrInvullen.SetError(Me.TbPostcode, " Geef een (correct) postcode in. ")
    TbPostcode.Text = ""
Else
    Me.ErrInvullen.SetError(Me.TbPostcode, "")
End If

    If TbPostcode.Text.ToString.Length > 4 Then
    TbPostcode.Text = ""
    Me.ErrInvullen.SetError(Me.TbPostcode, " Geef een correct postcode. ")
    MsgBox("Geef een correct postcode in.")
End If
End Sub

Private Sub TbAdres_TextChanged(sender As System.Object, e As System.EventArgs) Handles TbAdres.TextChanged

    If TbAdres.Text = ""
Then
    Me.ErrInvullen.SetError(Me.TbAdres, " Geef het address in. ")
Else
    Me.ErrInvullen.SetError(Me.TbAdres, "")
End If
End Sub

Private Sub TbVoornaam_TextChanged(sender As System.Object, e As System.EventArgs) Handles TbVoornaam.TextChanged

    If TbVoornaam.Text = ""
    Or IsNumeric(Me.TbVoornaam.Text) Then
    Me.ErrInvullen.SetError(Me.TbVoornaam, " Geef een Voornaam in. ")
Else
    Me.ErrInvullen.SetError(Me.TbVoornaam, "")
End If
End Sub

Private Sub TbNaam_TextChanged(sender As System.Object, e As System.EventArgs) Handles TbNaam.TextChanged


    If TbNaam.Text = ""
    Or IsNumeric(Me.TbNaam.Text) Then
    Me.ErrInvullen.SetError(Me.TbNaam, " Geef een naam in. ")
Else
    Me.ErrInvullen.SetError(Me.TbNaam, "")
End If
End Sub
End Class

0 个答案:

没有答案