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)
-   -   insercion en ado (https://www.clubdelphi.com/foros/showthread.php?t=41849)

vroa74 27-03-2007 20:59:02

insercion en ado
 
Hola:
estoy modificando un codigo que me dieron, solo que no tengo la menor idea de que hacer con este codigo.
Para entrar mas en tema le comento.
no se como hace la insecion de los datos y la verdad no tengo idea.
debo insertar datos [integer,string,date,memo,time.]

Código Delphi [-]
function miDB.ag_ejemplo(ejemplo: TTejemplo): Integer;
var
  mio: TADODataSet;
  tptStream: TMemoryStream;
  id: Integer;
begin
  // get DB data and append one row
  mio := TADODataSet.Create(nil);
  mio.Connection := connection;
  mio.CursorType := ctStatic;
  mio.LockType := ltOptimistic;
  mio.CommandText := 'SELECT * FROM MyData';
  mio.Open();
  mio.Append();
  tptStream := TMemoryStream.Create();
  tptStream.write(template.tpt^, template.size);

  (mio.FieldByName('template') as  TBlobField).LoadFromStream(tptStream);
//******************************************************
(mio.FieldByName('nombres') as  Tstring).????????????????????????????
(mio.FieldByName('apaterno') as  Tstring).????????????????????????????
(mio.FieldByName('amaterno') as  Tstring).????????????????????????????
(mio.FieldByName('fecha') as  Tdate).????????????????????????????
(mio.FieldByName('cp.') as  Tinteger).????????????????????????????
(mio.FieldByName('id_control') as  Tinteger).????????????????????????????
(mio.FieldByName('nombres') as  Tstring).????????????????????????????
//******************************************************
  mio.post();
  // get the ID of enrolled template.
  id := mio.FieldByName('ID').AsInteger;

  tptStream.Free();
  mio.Close();
  mio.Free();
  ag_ejemplo := id;
end;
:confused::confused::confused:
Muchas gracias por su ayuda.

vroa74 28-03-2007 00:13:27

ya solucione mi problema.

Código Delphi [-]function miDB.ag_ejemplo(ejemplo: TTejemplo): Integer; var mio: TADODataSet; tptStream: TMemoryStream; id: Integer; begin // get DB data and append one row mio := TADODataSet.Create(nil); mio.Connection := connection; mio.CursorType := ctStatic; mio.LockType := ltOptimistic; mio.CommandText := 'SELECT * FROM MyData'; mio.Open(); mio.Append(); tptStream := TMemoryStream.Create(); tptStream.write(template.tpt^, template.size); (mio.FieldByName('template') as TBlobField).LoadFromStream(tptStream); //****************************************************** mio.FieldByName('nombres').AsString := template.Tnombres; mio.FieldByName('apaterno').AsString := template.Tapaterno; mio.FieldByName('amaterno').AsString := template.Tamaterno; mio.FieldByName('fecha').AsDateTime:= template.Tfecha; mio.FieldByName('direccion').AsString := template.Tdireccion; mio.FieldByName('depto').AsString := template.Tdepto; mio.FieldByName('cp').AsInteger := template.TCP; mio.FieldByName('colonia').AsString := template.Tcolonia; mio.FieldByName('nempleado').AsInteger := template.Tnempleado; //****************************************************** mio.post(); // get the ID of enrolled template. id := mio.FieldByName('ID').AsInteger; tptStream.Free(); mio.Close(); mio.Free(); ag_ejemplo := id; end;


La franja horaria es GMT +2. Ahora son las 09:49:16.

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