Foros Club Delphi

Foros Club Delphi (https://www.clubdelphi.com/foros/index.php)
-   Conexión con bases de datos (https://www.clubdelphi.com/foros/forumdisplay.php?f=2)
-   -   eliminar registros con VS2008 (https://www.clubdelphi.com/foros/showthread.php?t=61093)

Tasslehoff 25-10-2008 08:56:41

eliminar registros con VS2008
 
Buenas noches,

Tengo un problema a la hora de eliminar registros, tengo una BBDD de Access que (al estar en red) conecto para leer/crear/editar/borrar y desconecto posteriormente. Todo va perfecto, exceptuando cuando quiero borrar un registro, ya que cuando lo borro, el registro desaparece, pero al volver a conectarme a la BBDD vuelve a aparecer. Os pego el código para ver si hay algún error:

PrivateSub Conectar()
Dim sCnn AsString = "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & Environment.CurrentDirectory & "\base.mdb"
Dim sSel AsString = "SELECT * FROM Venta ORDER BY CAMPO01"
da = New OleDbDataAdapter(sSel, sCnn)
Dim cbf AsNew OleDbCommandBuilder(da)
da.UpdateCommand = cbf.GetUpdateCommand
da.InsertCommand = cbf.GetInsertCommand
da.DeleteCommand = cbf.GetDeleteCommand
da.MissingSchemaAction = MissingSchemaAction.AddWithKey
dt =
New DataTable
da.Fill(dt)
EndSub

PrivateSub Eliminar()
dt.Rows.RemoveAt(registro) ' Donde registro es la variable que contiene el index de la fila

EndSub
PrivateSub DesConectar()
dr =
Nothing
dt = Nothing

da =
NothingEndSub



Lo dicho, después de eliminar, paso a una rutina que muestra los datos actualizados (después del borrado), pero en ese instante vuelve a aparecer, este sería el código de mostrar los datos

PrivateSub Mostrar_Datos()
If dt.Rows.Count = 0 ThenExitSub
dr = dt(Registro)
txtNumber.Text =
"" & dr(1).ToString
txtFecha.Text =
"" & dr(2).ToString
txtCodigo.Text =
"" & dr(3).ToString
txtNombre.Text =
"" & dr(4).ToString
txtCif.Text =
"" & dr(5).ToString
txtTelefono.Text =
"" & dr(6).ToString
txtDireccion.Text =
"" & dr(7).ToString
txtCP.Text =
"" & dr(8).ToString
txtPoblacion.Text =
"" & dr(9).ToString
EndSub

Por favor, ayudadme que tengo que entregar el programa la semana que viene y estoy atascado.

Gracias y salu2


La franja horaria es GMT +2. Ahora son las 16:00:37.

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2026, Jelsoft Enterprises Ltd.
Traducción al castellano por el equipo de moderadores del Club Delphi