I am trying to delete a register from my grid using this but nothing happens !!! My Database is a mdb file (Access)
when i click in delete link nothing happens....
any help ???
Thanks
Jr
Protected Sub RadGrid1_DeleteCommand(ByVal source As Object, ByVal e As Telerik.WebControls.GridCommandEventArgs) Handles RadGrid1.DeleteCommand |
Dim objConn1 As OleDbConnection |
Dim strCaminho As String = Server.MapPath("~/adm/bd/observatorio.mdb") |
objConn1 = New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & strCaminho & ";") |
Dim SqlCommand As New OleDbCommand() |
'Get the GridDataItem of the RadGrid |
Dim item As GridDataItem = DirectCast(e.Item, GridDataItem) |
'Get the primary key value using the DataKeyValue. |
Dim NEWSID As String = item.OwnerTableView.DataKeyValues(item.ItemIndex)("news_id").ToString() |
Try |
'Open the SqlConnection |
objConn1.Open() |
Try |
Dim deleteQuery As String = "DELETE from tblNoticias where news_id='" & NEWSID & "'" |
SqlCommand.CommandText = deleteQuery |
SqlCommand.Connection = objConn1 |
SqlCommand.ExecuteNonQuery() |
'Close the SqlConnection |
objConn1.Close() |
Catch ex As Exception |
Response.Write(ex.Message) |
'Me.lblError.Text = "Ocorreu um erro na tentativa de excluir o registro !" |
Exit Sub |
End Try |
Catch ex As Exception |
Me.lblError.Text = "Não foi possível abrir o banco de dados" |
Exit Sub |
End Try |
End Sub |
any help ???
Thanks
Jr