Club Delphi  
    FTP   CCD     Buscar   Trucos   Trabajo   Foros

Retroceder   Foros Club Delphi > Principal > Conexión con bases de datos
Registrarse FAQ Miembros Calendario Guía de estilo Buscar Temas de Hoy Marcar Foros Como Leídos

Conexión con bases de datos

Respuesta
 
Herramientas Buscar en Tema Desplegado
  #1  
Antiguo 25-11-2009
Avatar de ppb
[ppb] ppb is offline
Miembro Premium
 
Registrado: jun 2005
Ubicación: España
Posts: 109
Poder: 19
ppb Va por buen camino
Delphi 2010 + dbExpress

Hola a todos,



Estoy haciendo una aplicación que recibe , a través de TcpServer , datos
que graba en una BD MySql ; para el acceso a las tablas utilizo dbExpress con
"TSqlConnection->TSqlTable->TDataSetProvider->TClientDataSet". Cuando
hago el "ClientDataSet.RefreshRecord" devuelve "Record not found or changed by another user".( que he leido que es lo que hay que utilizar )
Lo he cambiado por "ClientDataSet.Refresh" pero cuando la tabla esta vacía ( y sólo en este caso ) inserto 1 ó mas registros y no se reflejan los cambios. Si la tabla tiene algún registro funciona bien.

Código:
DModuleMain.ClientDataSetPacientes.Insert;
DModuleMain.ClientDataSetPacientes.FieldByName('Campo').AsDateTime:=Now;
....
....
DModuleMain.ClientDataSetPacientes.Post;

DModuleMain.ClientDataSetPacientes.ApplyUpdates(0);
//DModuleMain.ClientDataSetPacientes.RefreshRecord;
DModuleMain.ClientDataSetPacientes.Refresh;
entorno : Delphi 2010 + MySql 5.1

¿ alguien puede echarme una mano ?

Gracias.

Un saludo.
__________________
Because , I have a power.
Responder Con Cita
  #2  
Antiguo 26-11-2009
Avatar de Al González
[Al González] Al González is offline
In .pas since 1991
 
Registrado: may 2003
Posts: 5.604
Poder: 29
Al González Es un diamante en brutoAl González Es un diamante en brutoAl González Es un diamante en brutoAl González Es un diamante en bruto
¡Hola!

¿Cómo has establecido la propiedad UpdateMode del proveedor y la propiedad ProviderFlags de los campos persistentes?

Respecto a querer refrescar un registro tras aplicarlo a la base de datos, te recomiendo leer este hilo: http://www.clubdelphi.com/foros/showthread.php?t=62154

Saludos.

Al González.
Responder Con Cita
  #3  
Antiguo 27-11-2009
Avatar de ppb
[ppb] ppb is offline
Miembro Premium
 
Registrado: jun 2005
Ubicación: España
Posts: 109
Poder: 19
ppb Va por buen camino
Cita:
Empezado por Al González Ver Mensaje
¡Hola!

¿Cómo has establecido la propiedad UpdateMode del proveedor y la propiedad ProviderFlags de los campos persistentes?
Gracias Al , por tu ayuda .
He echado un vistazo el hilo que comentas y no se si me puede valer.
Tengo el mismo escenario del hilo , dos tablas, utilizo un campo de la primera
para referenciar en la segunda , da la casualidad que el campo del que hablo
es el indice principal de primera tabla y ademas es AutoInc ( propiedad AutoGenerateValue = arAutoInc), con lo cual no se su valor a priori.
En la BD MySql si están los registros , pero cuando quiero recuperar el
indice después de hacer el refresh , siempre me devuelve 0 , solo pasa
cuando la tabla está vacía, si existen registros funciona bien.


campo indice ProviderFlags [pfInUpdate,pfInWhere,pfInKey]
resto ProviderFlags [pfInUpdate,pfInWhere]


la propiedad UpdateMode la tenia a "upWhereAll" la ha cambiado a "upWhereKeyOnly" pero sigue pasando los mismo.


Si se te ocurre algo mas , ya sabes .

Gracias de nuevo por tu ayuda.
__________________
Because , I have a power.
Responder Con Cita
  #4  
Antiguo 28-11-2009
toni.vi toni.vi is offline
Miembro
 
Registrado: may 2003
Ubicación: Sant Fost(Barcelona)
Posts: 102
Poder: 21
toni.vi Va por buen camino
Utiliza upWhereChanged en UpdateMode
Responder Con Cita
  #5  
Antiguo 28-11-2009
Avatar de rgstuamigo
rgstuamigo rgstuamigo is offline
Miembro
 
Registrado: jul 2008
Ubicación: Santa Cruz de la Sierra-Bolivia
Posts: 1.646
Poder: 17
rgstuamigo Va por buen camino
Arrow

De la ayuda de Delphi7>
Cita:
Client datasets work with an in-memory snapshot of the data from the source dataset. If the source dataset represents server data, then as time elapses other users may modify that data. The data in the client dataset becomes a less accurate picture of the underlying data.

Like any other dataset, client datasets have a Refresh method that updates its records to match the current values on the server. However, calling Refresh
only works if there are no edits in the change log. Calling Refresh when there are unapplied edits results in an exception.

Client datasets can also update the data while leaving the change log intact. To do this, call the RefreshRecord method. Unlike the Refresh method, RefreshRecord updates only the current record in the client dataset. RefreshRecord changes the record value originally obtained from the provider but leaves any changes in the change log.

Warning

It is not always appropriate to call RefreshRecord. If the user's edits conflict with changes made to the underlying dataset by other users, calling RefreshRecord masks this conflict. When the client dataset applies its updates, no reconcile error occurs and the application can't resolve the conflict.

In order to avoid masking update errors, you may want to check that there are no pending updates before calling RefreshRecord. For example, the following AfterScroll refreshes the current record every time the user moves to a new record (ensuring the most up-to-date value), but only when it is safe to do so.:

Código Delphi [-]
procedure TForm1.ClientDataSet1AfterScroll(DataSet: TDataSet);
begin
  if ClientDataSet1.UpdateStatus = usUnModified then 
    ClientDataSet1.RefreshRecord; 
end;
Hechale una miradita..
Saludos...
__________________
"Pedid, y se os dará; buscad, y hallaréis; llamad, y se os abrirá." Mt.7:7

Última edición por rgstuamigo fecha: 28-11-2009 a las 15:47:01.
Responder Con Cita
  #6  
Antiguo 29-11-2009
Avatar de ppb
[ppb] ppb is offline
Miembro Premium
 
Registrado: jun 2005
Ubicación: España
Posts: 109
Poder: 19
ppb Va por buen camino
Gracias rgs ,
salta una excepción solo cuando la tabla esta vacía
exception class EDBClient with message 'At beginning of table'"
no se si al final tendré que hacer una chapuzilla para salir de aquí . como crear una registro inútil cuando la tabla este vacía o algo así.

de nuevo gracias por vuestro tiempo

también he probado la sugerencia de toni.vi y el resultado es el mismo.
__________________
Because , I have a power.

Última edición por ppb fecha: 29-11-2009 a las 15:10:45.
Responder Con Cita
Respuesta


Herramientas Buscar en Tema
Buscar en Tema:

Búsqueda Avanzada
Desplegado

Normas de Publicación
no Puedes crear nuevos temas
no Puedes responder a temas
no Puedes adjuntar archivos
no Puedes editar tus mensajes

El código vB está habilitado
Las caritas están habilitado
Código [IMG] está habilitado
Código HTML está deshabilitado
Saltar a Foro

Temas Similares
Tema Autor Foro Respuestas Último mensaje
Seminario Web Delphi 2010 - Spanish TrUnkS Internet 17 20-03-2011 15:39:05
Delphi 2010 gerardus Debates 5 30-11-2009 21:46:53
TFrogFax en delphi 2010 xerkan Varios 0 17-11-2009 10:00:11
Delphi 2010 y odbc romeroja Conexión con bases de datos 1 17-11-2009 03:51:47
Update 2 y 3 de Delphi 2010 jcarteagaf Noticias 2 12-11-2009 20:23:46


La franja horaria es GMT +2. Ahora son las 13:50:32.


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