Consejo para manejar una info
#1
Escrito 10 marzo 2013 - 05:17
estoy realizando un programa en XE2 en el que necesito guardar una información de varios tipos de datos y quiero que sea en un archivo simple de texto (que posteriormente cifrare de ser necesario), he leído acerca de usar bases de datos pero la mayoría requiere la instalación de programas y no quiero nada así también leí sobre usar archivos XML pero no se si pueda funcionar como base de datos que consejos me dan?
un ejemplo de de los datos que quiero guardar son
X0000000, dd/mm/aaaa, dd/mm/aaaa, 00
donde seria un identificador, dos fechas y un valor entero por cada entrada
#2
Escrito 10 marzo 2013 - 05:39
Saludos
#3
Escrito 10 marzo 2013 - 05:43
#4
Escrito 10 marzo 2013 - 08:39
#5
Escrito 10 marzo 2013 - 09:03
Usar archivos CSV en modo tabla con Delphi y ADO
Saludox !
#6
Escrito 10 marzo 2013 - 09:09
usando esta linea de conexion que es donde se supone que esta el error:
ADOConnection1.ConnectionString := 'Provider=Microsoft.JET.OLEDB.4.0;Data Source='+RUTA+';Extended Properties=”text;HDR=Yes;FMT=Delimited(,)”';
y donde RUTA tiene actualmente este valor "C:\Users\Usuario\Documents\Delphi\Proyecto\db.csv"
por eso decidí preguntar de nuevo
#7
Escrito 10 marzo 2013 - 09:13
En el ConnectionString únicamente debes agregar el directorio y el nombre del archivo será usado como nombre de tabla en el dataset que vayas a emplear...
Saludox !
#8
Escrito 10 marzo 2013 - 09:16
#9
Escrito 10 marzo 2013 - 09:19
Otra cosa que puedes intentar es poner tu archivo directamente en C: y probar, vamos eliminando posibles obstáculos...
Saludox !
#10
Escrito 10 marzo 2013 - 09:31
unit Unit1; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls, DateUtils, Data.DB, Data.Win.ADODB, Vcl.ExtCtrls, Vcl.DBCtrls; type TForm1 = class(TForm) Memo1: TMemo; Label1: TLabel; Memo2: TMemo; Label2: TLabel; Button1: TButton; Button2: TButton; ADOConnection1: TADOConnection; procedure Button1Click(Sender: TObject); procedure Button2Click(Sender: TObject); procedure FormCreate(Sender: TObject); private { Private declarations } public { Public declarations } end; var NOMBRE, STRAUX: String; Form1: TForm1; REFDESDE, ULTCLICK, FECHAHOY: TDate; PROMEDIO: Single; DIAREF, DIAINA, CANREF, CANCLICK: Integer; implementation {$R *.dfm} procedure TForm1.Button1Click(Sender: TObject); var i, TL: Integer; AUX: String; begin FECHAHOY := date(); ShortDateFormat := 'yyyy/mm/dd'; CANREF := Memo1.Lines.Count; for i := 0 to (CANREF - 1) do begin NOMBRE := ''; AUX := ''; STRAUX := Memo1.Lines.Strings[i]; while STRAUX[1] <> ',' do begin NOMBRE := NOMBRE + STRAUX[1]; Delete(STRAUX, 1, 1); end; Delete(STRAUX, 1, 1); while STRAUX[1] <> ',' do begin AUX := AUX + STRAUX[1]; Delete(STRAUX, 1, 1); end; REFDESDE := StrToDate(AUX); AUX := ''; Delete(STRAUX, 1, 1); while STRAUX[1] <> ',' do begin AUX := AUX + STRAUX[1]; Delete(STRAUX, 1, 1); end; ULTCLICK := StrToDate(AUX); Delete(STRAUX, 1, 1); CANCLICK := StrToInt(STRAUX); DIAREF := DaysBetween(REFDESDE, FECHAHOY); DIAINA := DaysBetween(ULTCLICK, FECHAHOY); PROMEDIO := CANCLICK / DIAREF; if (DIAINA = 5) and (PROMEDIO < 1.400) then begin Memo2.Lines.Add(NOMBRE + ' RECICLAR'); end else begin if (DIAINA = 6) and (PROMEDIO < 1.701) then begin Memo2.Lines.Add(NOMBRE + ' RECICLAR'); end else begin if (DIAINA > 6) and (DIAINA <= 9) and (PROMEDIO <= 2.000) then begin Memo2.Lines.Add(NOMBRE + ' RECICLAR'); end else begin if (DIAINA >= 9) and (PROMEDIO > 2.000) then begin Memo2.Lines.Add(NOMBRE + ' RECICLAJE AUTOMATICO'); end end end end; if (DIAREF >= 60) and (PROMEDIO <= 1.350) then begin Memo2.Lines.Add(NOMBRE + ' RECICLAR'); end else begin if (DIAREF >= 45) and (PROMEDIO <= 1.300) then begin Memo2.Lines.Add(NOMBRE + ' RECICLAR'); end else begin if (DIAREF >= 30) and (PROMEDIO <= 1.250) then begin Memo2.Lines.Add(NOMBRE + ' RECICLAR'); end else begin if (DIAREF >= 15) and (PROMEDIO <= 1.200) then begin Memo2.Lines.Add(NOMBRE + ' RECICLAR'); end end end end; if (CANCLICK = 0) and (DIAREF >= 3) then begin Memo2.Lines.Add(NOMBRE + ' RECICLAR'); end end end; procedure TForm1.Button2Click(Sender: TObject); begin Form1.Close; end; procedure TForm1.FormCreate(Sender: TObject); var RUTA : String ; begin RUTA := ExtractFilePath(ParamStr(0))+'db.csv'; Memo1.Lines.Add(RUTA); ADOConnection1.ConnectionString := 'Provider=Microsoft.JET.OLEDB.4.0;Data Source='+RUTA+';Extended Properties=”text;HDR=Yes;FMT=Delimited(,)”'; ADOConnection1.Connected := TRUE; end; end.
ese es todo mi código y ya probé pasando el archivo a C: y me sigue dando el mismo error
(posiblemente el código de asco en algunas partes xD soy programador noob estoy haciendo este código por necesidad jaja)
pd: parte del código es como hago actualmente el proceso y es lo que quiero sustituir por la base de datos
#11
Escrito 10 marzo 2013 - 09:59
#12
Escrito 10 marzo 2013 - 10:06
#13
Escrito 10 marzo 2013 - 10:10
Haz la modificación que te digo y coméntanos...
Saludox !
#14
Escrito 10 marzo 2013 - 10:16
#15
Escrito 10 marzo 2013 - 10:26
Saludox !
#16
Escrito 10 marzo 2013 - 10:41
var Ruta: String; begin Ruta := 'C:\Apache24'; Conexion.Connected := False; Conexion.ConnectionString := 'Provider=Microsoft.Jet.OLEDB.4.0;Data Source='+ Ruta+';Extended Properties="Text;HDR=Yes;'+ 'FMT=Delimited(,);";Persist Security Info=False'; try Conexion.Connected := True; Showmessage('Conexión exitosa !'); except on e:exception do Showmessage('Error en la conexión...'+#10#13+e.Message); end;
Coméntanos !
Saludox !
#17
Escrito 11 marzo 2013 - 08:43
#18
Escrito 11 marzo 2013 - 10:55
MiLista:= TStringList.create; MiRecord:= TStringList.create; MiRecord.Delimiter:= #10; for i:= 0 to MiLista.Count-1 do begin MiRecord.Clear; MiRecord.Text:= MiLista.Items[i]; for j:= 0 to MiRecord.Count-1 do ShowMessage('El campo '+IntToStr(j)+' del record '+IntToStr(i)+ ' contiene el texto '+QuotedStr(MiRecord[j]); end;
Lo del delimiter es de memoria, creo que se llamaba así pero igual me equivoco.