Pues eso, me da error al momento de agregar mi nuevo registro a la base de datos ACCESS (*.dbacc).
Tengo un formulario con un
DATAGRIDVIEW (DGV_Clientes) que me muestra la tabla
CLIENTES de mi base de datos en ACCESS 2007. Al hacer click en la opcion
NUEVO muestro un segundo formulario con
TEXTBOXES para añadir el nuevo registro y el boton
AGREGAR para realizar la accion y cerrar el segundo form.
Aca el código del boton
AGREGAR:
PrivateSub btn_AGREGAR_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn_AGREGAR.Click
Dim cb AsNew OleDb.OleDbCommandBuilder(da)
Dim dsNewRow AsDataRow
dsNewRow = ds.Tables("Clientes").NewRow()
dsNewRow.Item("Cod_Cliente") = Nuevo_Codigo("Clientes") <-- Crea: CLI0004, CLI0005....
dsNewRow.Item("Nombre") = txt_NOMBRE.Text
dsNewRow.Item("Telefono") = txt_TELEFONO.Text
dsNewRow.Item("Direccion") = txt_DIRECCION.Text
-- El siguiente comando me añade el nuevo registro al DataSet
y automaticamente lo muestra en el DATAGRIDVIEW
... funciona de maravilla --
ds.Tables("Clientes").Rows.Add(dsNewRow)
--- Se supone que este comando debería
actualizar mi BaseDatos.dbacc agregando
el nuevo registro en ds.Tables("Clientes") ---
da.Update(ds, "Clientes") <--- AQUI ME DA ERROR
EndSub
El mensaje de error dice:
Update requiere que InsertCommand sea válido cuando se pasa la colección DataRow con nuevas filas.
Ya utilicé este código anteriormente y siempre me funcionó sin problemas.... QUE ESTOY HACIENDO MAL !!!!!!
GRACIAS POR SU AYUDA !!!