Club Delphi  
    FTP   CCD     Buscar   Trucos   Trabajo   Foros

Retroceder   Foros Club Delphi > Principal > Varios
Registrarse FAQ Miembros Calendario Guía de estilo Temas de Hoy

Grupo de Teaming del ClubDelphi

Respuesta
 
Herramientas Buscar en Tema Desplegado
  #1  
Antiguo 21-12-2021
Avatar de kuan-yiu
[kuan-yiu] kuan-yiu is offline
Miembro Premium
 
Registrado: jun 2006
Ubicación: Galicia. España.
Posts: 1.017
Poder: 20
kuan-yiu Va camino a la fama
A simple vista ya hay algo.
Si en la BD es de 80 no puedes darle de tamaño 100 porque te dará error al guardar.
Cita:
Empezado por feliz-58 Ver Mensaje
La tabla es Productos.
Mi campo en la tabla es Descripcion Nvarchar 80.
SQL Server.
(...)
Código Delphi [-]
TfacturaDescripcion.size := 100;
Tafactura.Active;
Me da error de fuera de Rango.
Prueba poniendo 80 y determina el punto exacto en el que salta el error o en donde pierde el tamaño.
No es un comportamiento normal que cambie de tamaño así por las buenas.
Responder Con Cita
  #2  
Antiguo 21-12-2021
feliz-58 feliz-58 is offline
Miembro
 
Registrado: sep 2012
Posts: 314
Poder: 12
feliz-58 Va por buen camino
Cita:
Empezado por kuan-yiu Ver Mensaje
A simple vista ya hay algo.
Si en la BD es de 80 no puedes darle de tamaño 100 porque te dará error al guardar.


Prueba poniendo 80 y determina el punto exacto en el que salta el error o en donde pierde el tamaño.
No es un comportamiento normal que cambie de tamaño así por las buenas.
Ya encontre el problema, la solucion esta en que, cuando modificas el tamaño de un campo, en ves de activar y desactivar el ClientDataSet, hay que dale a crear otra vez. (Clic Derecho, Crear DataSet) y los cambio si se guardan
Responder Con Cita
  #3  
Antiguo 21-12-2021
feliz-58 feliz-58 is offline
Miembro
 
Registrado: sep 2012
Posts: 314
Poder: 12
feliz-58 Va por buen camino
Cita:
Empezado por kuan-yiu Ver Mensaje
A simple vista ya hay algo.
Si en la BD es de 80 no puedes darle de tamaño 100 porque te dará error al guardar.


Prueba poniendo 80 y determina el punto exacto en el que salta el error o en donde pierde el tamaño.
No es un comportamiento normal que cambie de tamaño así por las buenas.
Gracias por la ayuda y el interes.
Responder Con Cita
  #4  
Antiguo 21-12-2021
Avatar de movorack
[movorack] movorack is offline
Miguel A. Valero
 
Registrado: feb 2007
Ubicación: Bogotá - Colombia
Posts: 1.346
Poder: 20
movorack Va camino a la famamovorack Va camino a la fama
¡Hola, feliz-58!

De pronto algo de este helper, pueda serte útil.

Código Delphi [-]
uses
  System.RegularExpressions;

type
  TMyClientDatasetHelper = class helper for TClientDataset
  Private
  Public
    procedure CopyCurrentRecord(DataSet: TDataset; IgnoreFieldNames: array of string); overload;

    procedure CopyCurrentRecord(DataSet: TDataset); overload;

    procedure CopyData(DataSet: TDataset; IgnoreFieldNames: array of string); overload;

    procedure CopyData(DataSet: TDataset); overload;

     procedure InicLocal(XMLSource: string = ''; LogChanges: Boolean = False);

     procedure FinaLocal(XMLFileName : string = '');
  end; 

{ TMyClientDatasetHelper }

procedure TMyClientDatasetHelper.CopyCurrentRecord(DataSet: TDataset;
  IgnoreFieldNames: array of string);
  function IgnoreField(FieldName: string): Boolean;
    var
      lFieldName : String;
  begin
    Result := False;
    for lFieldName in IgnoreFieldNames do
    begin
      Result := SameText(FieldName.Trim, lFieldName.trim);
      if Result then
        Break;
    end;
  end;
  var
    lField: TField;
begin
  if (not Dataset.Active) or Dataset.IsEmpty then
    Exit;

  if not (Self.State in [dsEdit, dsInsert]) then
    if Self.IsEmpty then
      Self.Append
    else
      Self.Edit;

  for lField in Self.Fields do
  begin
    if IgnoreField(lField.FieldName) then
      Continue;

    if not Assigned(DataSet.FindField(lField.FieldName)) then
      Continue;

    if lField.IsBlob then
    begin
      try
        //Se intenta realizar la copia
        lField.AsBytes := DataSet.FieldByName(lField.FieldName).AsBytes
      except
      end;
    end
    else
    if (lField.Value <> DataSet.FieldByName(lField.FieldName).Value) then
      lField.Value := DataSet.FieldByName(lField.FieldName).Value;
  end;
end;

procedure TMyClientDatasetHelper.CopyCurrentRecord(DataSet: TDataset);
begin
  CopyCurrentRecord(DataSet, []);
end;

procedure TMyClientDatasetHelper.CopyData(DataSet: TDataset);
begin
  CopyData(DataSet, []);
end;

procedure TMyClientDatasetHelper.CopyData(DataSet: TDataset;
  IgnoreFieldNames: array of string);
  var
    BookMark: TBookmark;
begin
  if (not DataSet.Active) or DataSet.IsEmpty then
    Exit;

  if Self.State in [dsEdit, dsInsert] then
    Self.Cancel;

  BookMark := nil;
  try
    DataSet.DisableControls;
    Self.DisableControls;
    BookMark := DataSet.GetBookmark;

    DataSet.First;
    while not DataSet.Eof do
    begin
      Self.Append;
      CopyCurrentRecord(Dataset, IgnoreFieldNames);
      Self.Post;
      Dataset.Next;
    end;

    Self.First;
  finally
    if Assigned(BookMark) and Dataset.BookmarkValid(BookMark) then
      DataSet.GotoBookmark(BookMark);

    DataSet.EnableControls;
    Self.EnableControls;
  end;
end;

procedure TMyClientDatasetHelper.FinaLocal(XMLFileName: string);
begin
  if Self.State in [dsInsert, dsEdit] then
    Self.Post;

  if not XMLFileName.Trim.IsEmpty then
  begin
    if FileExists(XMLFileName) then
      DeleteFile(XMLFileName);

    Self.SaveToFile(XMLFileName, dfXMLUTF8);
  end;
end;

procedure TMyClientDatasetHelper.InicLocal(XMLSource: string;
  LogChanges: Boolean);
  var
    lCds: TClientDataSet;
begin
  if (not (Self is TClientDataSet))
    or Assigned(Self.RemoteServer)
    or (not Self.ProviderName.Trim.IsEmpty)
  then
    Exit;

  //Se inicializa el dataset vacio
  if Self.DataSize > 0 then
    Self.Close;
  Self.FieldDefs.Clear;

  if Self.FieldCount > 0 then
  begin
    Self.CreateDataSet;
    Self.EmptyDataSet;
  end;

  if Self.Active then
    Self.LogChanges := LogChanges;

  if not XMLSource.Trim.IsEmpty then
  begin
    //Para evitar fallas de carga cuando la estructura del dataset no coincide,
    //se crea un dataset temporal para cargar el XML
    lCds := TClientDataSet.Create(Self);
    try
      //Se verifica si es un archivo.
      if FileExists(XMLSource) then
      begin
        try
          lCds.LoadFromFile(XMLSource);
        except
          on E: Exception do
          begin
            if FileExists(XMLSource) then
              DeleteFile(XMLSource);
            raise;
          end;
        end;
      end
      else
      //se verifica que sea una estructura XML
      if TRegEx.IsMatch(XMLSource, '\s*\<\?xml', [roIgnoreCase, roMultiLine]) then
      begin
        lCds.XMLData := XMLSource.Trim;
        lCds.Open;
      end;

      if lCds.Active then
      begin
        lCds.LogChanges := LogChanges;
        Self.CopyData(lCds);
      end;
    finally
      lCds.Free;
    end;
  end;

  if Self.Active and (not Self.IsEmpty) then
    Self.First;
end;
__________________
Buena caza y buen remar... http://mivaler.blogspot.com
Responder Con Cita
Respuesta



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
Campo mayor a 255 trex2000 Firebird e Interbase 2 18-05-2021 17:21:44
Microsoft.ACE.OLEDB.12.0 con nombre de archivo mayor a 8 caracteres aromigaret SQL 10 26-01-2017 18:07:37
Campo autoincremental en clientDataSet novato_erick Providers 0 13-04-2014 01:03:57
Buscar en un campo de una tabla por Caracteres Drago26 Tablas planas 2 23-10-2008 16:24:47
ClientDataSet y campo COMPUTED BY Jose Miguel Mun Firebird e Interbase 2 24-02-2007 15:29:48


La franja horaria es GMT +2. Ahora son las 12:07:57.


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