使用vb 2010避免ms访问时的数据冗余

时间:2014-03-08 16:09:09

标签: vb.net

关于如何确定我将在我的数据库中输入的信息是否存在或我的数据库中是否有相同的记录,我需要一些帮助。请帮助我...谢谢

这是我的SAVE BUTTON代码

Private Sub btnsave_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnsave.Click

rs = New ADODB.Recordset
With rs
    'check if important item is null '
    If txtappln.Text = "" Or txtappfn.Text = "" Or txtappmn.Text = "" Or txtclass.Text = "" Or txtcnum.Text = "" Or txtaddr.Text = "" Or txtbrgy.Text = "" Then
        MsgBox("Some object in the Applicant Personal Information or Classification or Ctrl Number is not filled up", MessageBoxIcon.Warning)
        .Cancel()
    Else
        'Save'
        .Open("Select * from Applicant", con, 2, 3)
        .AddNew()
        .Fields("LAST_NAME").Value = txtappln.Text
        .Fields("FIRST_NAME").Value = txtappfn.Text
        .Fields("MIDDLE_NAME").Value = txtappmn.Text
        .Fields("ADDRESS").Value = txtaddr.Text
        .Fields("CLASSIFICATION").Value = txtclass.Text
        .Fields("CONTROL_NO").Value = txtcnum.Text
        .Fields("BARANGAY").Value = txtbrgy.Text
        MsgBox("Record has been save !!", vbInformation)
        .Update()
        .Close()
    End If
End With`

0 个答案:

没有答案