Private Sub GridView1_RowDeleting(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewDeleteEventArgs) Handles GridView1.RowDeleting
Dim strConnString As String = "Server=localhost; User Id=root; Password=1; database= database_kku_dev; Pooling=false"
Dim dr As DataRow = dt.Rows(GridView1.Rows(e.RowIndex).DataItemIndex)
dr.Delete()
GridView1.DataSource = dt
GridView1.DataBind()
Dim sqldelete As String
sqldelete = "delete from bank where bank_id= '1' " 'ตอนนี้ใส่เเบบตรง ๆไปก่อน ติดตรงนี้ครับ
Try
With Conn
If .State = ConnectionState.Open Then .Close()
.ConnectionString = strConnString
.Open()
End With
pop = New MySqlCommand
With pop
.CommandType = CommandType.Text
.CommandText = sqldelete
.Connection = Conn
.ExecuteNonQuery()
End With
btnAdd.Visible = False
lblStatus.Visible = True
Catch ex As Exception
lblStatus.Text = "Record can not sqldelete"
End Try
lblStatus.Text = "Record sqldelete"
End Sub
Protected Sub myGridView_RowDeleting(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewDeleteEventArgs) Handles myGridView.RowDeleting
strSQL = "DELETE FROM customer WHERE CustomerID = '" & myGridView.DataKeys.Item(e.RowIndex).Value & "'"
objCmd = New OleDbCommand(strSQL, objConn)
objCmd.ExecuteNonQuery()
myGridView.EditIndex = -1
BindData()
End Sub
Private Sub GridView1_RowDeleting(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewDeleteEventArgs) Handles GridView1.RowDeleting
Dim strConnString As String = "Server=localhost; User Id=root; Password=1; database= database_kku_dev; Pooling=false"
Dim dr As DataRow = dt.Rows(GridView1.Rows(e.RowIndex).DataItemIndex)
dr.Delete()
GridView1.DataSource = dt
GridView1.DataBind()
Dim strSQL As String
' Dim btnDelete As Label = CType(GridView1.Rows(e.RowIndex).FindControl("bank_id"), Label)
'sqldelete = "Delete from bank where bank_id = '" & GridView1.DataKeys.Item(e.RowIndex).Value & "'"
strSQL = "DELETE FROM bank WHERE bank_id = '" & GridView1.DataKeys.Item(e.RowIndex).Value & "'"
Cmd = New MySqlCommand(strSQL, Conn)
Cmd.ExecuteNonQuery()
GridView1.EditIndex = -1
DataBind()
End Sub