Yo tengo terminado el Update pero no se como continuar con el borrado y el ingreso de datos.
Utilicé un SQLDataAdapter, SQLConnection, un DataSet que llené con los datos de la tabla Categories de la base Northwind que viene con el SQL.
Este es el código q estoy haciendo, q me sugieren?
Código:
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load SqlDataAdapter1.Fill(DsCategories1) If Not Page.IsPostBack Then 'Introducir aquí el código de usuario para inicializar la página DataGrid1.DataBind() End If End Sub Private Sub DataGrid1_EditCommand(ByVal source As Object, ByVal e As System.Web.UI.WebControls.DataGridCommandEventArgs) Handles DataGrid1.EditCommand DataGrid1.EditItemIndex = e.Item.ItemIndex DataGrid1.DataBind() End Sub Private Sub DataGrid1_CancelCommand(ByVal source As Object, ByVal e As System.Web.UI.WebControls.DataGridCommandEventArgs) Handles DataGrid1.CancelCommand DataGrid1.EditItemIndex = -1 DataGrid1.DataBind() End Sub Private Sub DataGrid1_UpdateCommand(ByVal source As Object, ByVal e As System.Web.UI.WebControls.DataGridCommandEventArgs) Handles DataGrid1.UpdateCommand Dim Key As String = DataGrid1.DataKeys(e.Item.ItemIndex).ToString() '(1) Dim sCategoryName, sCategoryDescription As String '(2) Dim tb As TextBox tb = CType(e.Item.Cells(3).Controls(0), TextBox) sCategoryName = tb.Text tb = CType(e.Item.Cells(4).Controls(0), TextBox) sCategoryDescription = tb.Text Dim r As DsCategories.CategoriesRow '(3) r = DsCategories1.Categories.FindByCategoryID(Key) r.CategoryName = sCategoryName '(4) 'los 1ros son los campos de la tabla r.Description = sCategoryDescription ' y los 2dos la var string SqlDataAdapter1.Update(DsCategories1) '(5) DataGrid1.DataBind() DataGrid1.EditItemIndex = -1 '(6) DataGrid1.DataBind() '(7) End Sub Private Sub DataGrid1_DeleteCommand(ByVal source As Object, ByVal e As System.Web.UI.WebControls.DataGridCommandEventArgs) Handles DataGrid1.DeleteCommand Dim strQuery As String Dim index As Integer index = e.Item.ItemIndex SqlDataAdapter1.uo(strQuery) ' Add code to delete data from data source. DataGrid1.DataBind() End Sub End Class