Re: [twsocket] ftp to Table

2005-10-04 Thread Guillaume MAISON
> Thanks
> 
> ms.Seek(0,0);
> 
>>DisplayMemo.Lines.Add(ms.DataString);
> 
> 
> Works great. It looks like ms.Seek is quit important sometimes. In case of
> using TMemoryStream its needed, TStringStream not all the time.

this is a bit off-Topic, but when dealing with streams,
when a third party component is using a stream that you provide,
when you get the stream back from a function, you'll always have to
"rewind" it to the position 0 (or seek(0, 0) ) if you want to have 
access to its content.

this is true for almost every TStream descendant.


>>>ms:=TStringStream.Create(data);
> 
> When using TStringStream.Create('') it's the same, seems like the var 'data'
> has no meaning here.

the TDataString constructor method enables you to provide a first string
to feed the stream with at its creation. If you don't want to fill it, 
passing '' is a solution :)

Best Regards,

-- 

Guillaume MAISON - [EMAIL PROTECTED]
83, Cours Victor Hugo
47000 AGEN
Tél : 05 53 87 91 48 - Fax : 05 53 68 73 50
e-mail : [EMAIL PROTECTED] - Web : http://nauteus.com

-- 
To unsubscribe or change your settings for TWSocket mailing list
please goto http://www.elists.org/mailman/listinfo/twsocket
Visit our website at http://www.overbyte.be


Re: [twsocket] ftp to Table

2005-10-04 Thread Werner

Thanks

ms.Seek(0,0);
> DisplayMemo.Lines.Add(ms.DataString);

Works great. It looks like ms.Seek is quit important sometimes. In case of
using TMemoryStream its needed, TStringStream not all the time.

> > ms:=TStringStream.Create(data);
When using TStringStream.Create('') it's the same, seems like the var 'data'
has no meaning here.

Thanks for your help
Werner



- Oorspronkelijk bericht - 
Van: "Guillaume MAISON" <[EMAIL PROTECTED]>
Aan: "ICS support mailing" 
Verzonden: dinsdag, oktober 04, 2005 11:57
Onderwerp: Re: [twsocket] ftp to Table


> >
> > I have a small file located on a FTP
> > I want to read this file, line per line, and save this data direct to a
> > local table.
> > So I don't need to save this file first to disk, and read it again.
> >
> > I took a look at the localSteam property, and tried this example.
> > The ms.Size give a number, but I can't get the stream into data?
> >
> > var
> > ms:TStringStream;
> > data:string;
> > begin
> > ms:=TStringStream.Create(data);
> > try
> > FtpClient1.HostName:= HostNameEdit.Text;
> > FtpClient1.Port  := PortEdit.Text;
> > FtpClient1.UserName:= UserNameEdit.Text;
> > FtpClient1.PassWord:= PassWordEdit.Text;
> > FtpClient1.HostDirName := HostDirEdit.Text;
> > FtpClient1.HostFileName:= HostFileEdit.Text;
> > FtpClient1.LocalStream := ms;
> > FtpClient1.Binary  := True;
> > FtpClient1.Receive;
> > DisplayMemo.lines.Add('Memorystream '+IntToSTr(ms.Size));
>
> > DisplayMemo.Lines.Add(data);
> You should replace this line by :
>
> ms.Seek(0,0);
> DisplayMemo.Lines.Add(ms.DataString);
>
> > finally
> > ms.Free;
> > end;
> > end;
>
> HTH,
>
> Best regards,
>
> -- 
>
> Guillaume MAISON - [EMAIL PROTECTED]
> 83, Cours Victor Hugo
> 47000 AGEN
> Tél : 05 53 87 91 48 - Fax : 05 53 68 73 50
> e-mail : [EMAIL PROTECTED] - Web : http://nauteus.com
>
> -- 
> To unsubscribe or change your settings for TWSocket mailing list
> please goto http://www.elists.org/mailman/listinfo/twsocket
> Visit our website at http://www.overbyte.be
>
>

-- 
To unsubscribe or change your settings for TWSocket mailing list
please goto http://www.elists.org/mailman/listinfo/twsocket
Visit our website at http://www.overbyte.be


Re: [twsocket] ftp to Table

2005-10-04 Thread Guillaume MAISON
> 
> I have a small file located on a FTP
> I want to read this file, line per line, and save this data direct to a
> local table.
> So I don't need to save this file first to disk, and read it again.
> 
> I took a look at the localSteam property, and tried this example.
> The ms.Size give a number, but I can't get the stream into data?
> 
> var
> ms:TStringStream;
> data:string;
> begin
> ms:=TStringStream.Create(data);
> try
> FtpClient1.HostName:= HostNameEdit.Text;
> FtpClient1.Port  := PortEdit.Text;
> FtpClient1.UserName:= UserNameEdit.Text;
> FtpClient1.PassWord:= PassWordEdit.Text;
> FtpClient1.HostDirName := HostDirEdit.Text;
> FtpClient1.HostFileName:= HostFileEdit.Text;
> FtpClient1.LocalStream := ms;
> FtpClient1.Binary  := True;
> FtpClient1.Receive;
> DisplayMemo.lines.Add('Memorystream '+IntToSTr(ms.Size));

> DisplayMemo.Lines.Add(data);
You should replace this line by :

ms.Seek(0,0);
DisplayMemo.Lines.Add(ms.DataString);

> finally
> ms.Free;
> end;
> end;

HTH,

Best regards,

-- 

Guillaume MAISON - [EMAIL PROTECTED]
83, Cours Victor Hugo
47000 AGEN
Tél : 05 53 87 91 48 - Fax : 05 53 68 73 50
e-mail : [EMAIL PROTECTED] - Web : http://nauteus.com

-- 
To unsubscribe or change your settings for TWSocket mailing list
please goto http://www.elists.org/mailman/listinfo/twsocket
Visit our website at http://www.overbyte.be


Re: [twsocket] ftp to Table

2005-10-04 Thread Werner



> > I like to use ics ftp to transfer the contents direct to a table and not
save it first to disk
> > Could this be possible?
> > Now I'm saving to contents to a file on disk, then read the file and
save the contents to the
> table, wich is time comsuming.
> >
> > Now:
> >
> > 1.open the ftp
> > 2. read one or more files from ftp
> > 3. save one or more files to disk
> > 4. read file from disk and save to table
> > 5. then close ftp
> >
> > I like to
> >
> > 1.open the ftp
> > 2. read file from ftp and save to table
> > 3. then close ftp
> >
> > If not possible with ftp, can this be done with socket to access an ftp
server
> > Would be great for an example
>
> Not sure I understand the problem. Do you mean you want to save a big file
located on a FTP to a
> table locate in a database accessible from a client PC ? Do you mean you
want to avoid saving the
> file to a local file first and save to the table "on the fly".
>
> On solution is to design a TSream derived class that when you write data
to it, data is written to
> your table. FTP component will then be able to use it with his LocalStream
property.
>

I have a small file located on a FTP
I want to read this file, line per line, and save this data direct to a
local table.
So I don't need to save this file first to disk, and read it again.

I took a look at the localSteam property, and tried this example.
The ms.Size give a number, but I can't get the stream into data?

var
ms:TStringStream;
data:string;
begin
ms:=TStringStream.Create(data);
try
FtpClient1.HostName:= HostNameEdit.Text;
FtpClient1.Port  := PortEdit.Text;
FtpClient1.UserName:= UserNameEdit.Text;
FtpClient1.PassWord:= PassWordEdit.Text;
FtpClient1.HostDirName := HostDirEdit.Text;
FtpClient1.HostFileName:= HostFileEdit.Text;
FtpClient1.LocalStream := ms;
FtpClient1.Binary  := True;
FtpClient1.Receive;
DisplayMemo.lines.Add('Memorystream '+IntToSTr(ms.Size));
DisplayMemo.Lines.Add(data);
finally
ms.Free;
end;
end;






>
> --
> Contribute to the SSL Effort. Visit
> http://www.overbyte.be/eng/ssl.html
> --
> [EMAIL PROTECTED]
> Author of ICS (Internet Component Suite, freeware)
> Author of MidWare (Multi-tier framework, freeware)
> http://www.overbyte.be
>
>
> -- 
> To unsubscribe or change your settings for TWSocket mailing list
> please goto http://www.elists.org/mailman/listinfo/twsocket
> Visit our website at http://www.overbyte.be
>
>

-- 
To unsubscribe or change your settings for TWSocket mailing list
please goto http://www.elists.org/mailman/listinfo/twsocket
Visit our website at http://www.overbyte.be


Re: [twsocket] ftp to Table

2005-10-04 Thread Francois Piette
> I like to use ics ftp to transfer the contents direct to a table and not save 
> it first to disk
> Could this be possible?
> Now I'm saving to contents to a file on disk, then read the file and save the 
> contents to the
table, wich is time comsuming.
>
> Now:
>
> 1.open the ftp
> 2. read one or more files from ftp
> 3. save one or more files to disk
> 4. read file from disk and save to table
> 5. then close ftp
>
> I like to
>
> 1.open the ftp
> 2. read file from ftp and save to table
> 3. then close ftp
>
> If not possible with ftp, can this be done with socket to access an ftp server
> Would be great for an example

Not sure I understand the problem. Do you mean you want to save a big file 
located on a FTP to a
table locate in a database accessible from a client PC ? Do you mean you want 
to avoid saving the
file to a local file first and save to the table "on the fly".

On solution is to design a TSream derived class that when you write data to it, 
data is written to
your table. FTP component will then be able to use it with his LocalStream 
property.


--
Contribute to the SSL Effort. Visit
http://www.overbyte.be/eng/ssl.html
--
[EMAIL PROTECTED]
Author of ICS (Internet Component Suite, freeware)
Author of MidWare (Multi-tier framework, freeware)
http://www.overbyte.be


-- 
To unsubscribe or change your settings for TWSocket mailing list
please goto http://www.elists.org/mailman/listinfo/twsocket
Visit our website at http://www.overbyte.be


Re: [twsocket] ftp to Table

2005-10-04 Thread Arno Garrels
Take a look at FtpCli's property LocalStream.
Don't forget that a transfer may fail.

Arno Garrels

Werner wrote:
> Hi
> 
> I like to use ics ftp to transfer the contents direct to a table and not
> save it first to disk Could this be possible?
> Now I'm saving to contents to a file on disk, then read the file and save
> the contents to the table, wich is time comsuming. 
> 
> Now:
> 
> 1.open the ftp
> 2. read one or more files from ftp
> 3. save one or more files to disk
> 4. read file from disk and save to table
> 5. then close ftp
> 
> I like to
> 
> 1.open the ftp
> 2. read file from ftp and save to table
> 3. then close ftp
> 
> If not possible with ftp, can this be done with socket to access an ftp
> server Would be great for an example
> 
> Thanks in advance for any response
> Werner
-- 
To unsubscribe or change your settings for TWSocket mailing list
please goto http://www.elists.org/mailman/listinfo/twsocket
Visit our website at http://www.overbyte.be


[twsocket] ftp to Table

2005-10-04 Thread Werner
Hi

I like to use ics ftp to transfer the contents direct to a table and not save 
it first to disk
Could this be possible?
Now I'm saving to contents to a file on disk, then read the file and save the 
contents to the table, wich is time comsuming.

Now:

1.open the ftp
2. read one or more files from ftp
3. save one or more files to disk
4. read file from disk and save to table
5. then close ftp

I like to

1.open the ftp
2. read file from ftp and save to table
3. then close ftp

If not possible with ftp, can this be done with socket to access an ftp server
Would be great for an example

Thanks in advance for any response
Werner
-- 
To unsubscribe or change your settings for TWSocket mailing list
please goto http://www.elists.org/mailman/listinfo/twsocket
Visit our website at http://www.overbyte.be