我对DELETE按钮有所帮助 起初我的代码是成功的。它可以删除vb程序中的数据以及位于MS Access的数据库的数据。
但是,当我向DELETE按钮添加一些验证时,添加一些MessageBoxstyle和MessageBoxButton它只是不起作用。它只删除文本框的条目而不删除数据本身。
我的问题是......
我的程序不仅要删除文本框中的数据,还要删除DataGridView上的数据,当我按下" YES"在确认消息上。当我点击“否”按钮时,它只会保持原样。你怎么做?
请有人帮助我。我是新手,还在学习。我还是学生,我真的需要这个系统...谢谢!
这是我的代码!
Imports System.Data.OleDb
导入System.Text.RegularExpressions
Public Class Monitoring_Form
Dim connect As OleDbConnection
Dim adapter As OleDbDataAdapter
Dim commnd As OleDbCommand
Dim dataset As DataSet
Dim datatable As DataTable
Dim table As DataTableCollection
Dim binding As New BindingSource
Dim id As Integer
Dim Email As Boolean
Private Sub btn_cdelete_Click(sender As System.Object, e As System.EventArgs) Handles btn_cdelete.Click
txt_customerID.Text = id
If MessageBox.Show("Are you sure you wan't to DELETE this record?", "Delete Confirmation", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) = Windows.Forms.DialogResult.Yes Then
commnd = New OleDbCommand("delete FROM CustomersInfo WHERE FirstName = '" + txt_firstname.Text + "'", connect)
commnd.ExecuteNonQuery()
MsgBox("ENTRY SUCCESSFULLY DELETED!")
txt_customerID.Text = ""
txt_firstname.Text = ""
txt_lastname.Text = ""
txt_add.Text = ""
txt_cnumber.Text = ""
txt_email.Text = ""
'' Me.dgv_1.Rows.RemoveAt(Me.dgv_1.CurrentRow.ToString())
Else
End If
End Sub
我刚刚编辑了我的问题,为你们清楚地说明了这一点。请帮忙,抱歉这个错误。
这是我的代码
的修订版