473,396 Members | 1,707 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

ftp-ado

Recently we've had some posts about ftp. I wrote my own ftp class a few
years ago and it works satisfactorily for me.

Today for a simple writing of text or binary to a file on a server I use
ADO rather than FTP (I'm using 2.8 and am not sure when this capability
occurred).

This creates or overwrites a file on my server. Then it writes some text to
that file.

A little investigation would allow one to modify this to transfer a file,
and/or to change the direction of transfer.

Sub temp()
Dim r As ADODB.Record
Dim s As ADODB.Stream
Set r = New ADODB.Record
Set s = New ADODB.Stream
' open the file for writing
' over write if it exists
' else create it
r.Open "http://www.ffdba.com/temporary.txt", , adModeWrite,
adCreateOverwrite
' windows xp asks for username and password here
' but will "remember" them if prompted
' (you can include them in your code, of course)
With s
' open a stream
' associated with the record
.Open r, , adOpenStreamFromRecord
' write some text
.WriteText "This is a test!"
.Close
End With
r.Close
End Sub

On http://www.ffdba.com a file called temporary.txt appears and its
contents are "This is a test!".

MS examples show setting r and s to nothing. I know of no reason to set
anything except DAO objects to nothing, but maybe you would like to do
this.

--
Lyle
--
Nov 13 '05 #1
5 2226
"Lyle Fairfield" <Lo******@FFDBA.Com> wrote
MS examples show setting r and s to nothing. I know of no reason to set
anything except DAO objects to nothing, but maybe you would like to do
this.

Lyle,

I'm definitely going to save your FTP code for later - no use today, but
tomorrow who knows - but I am interested now in the quoted part. Most ADO
code read sets the Recordset = Nothing; but other things I've read say that
the resources will be returned regardless. I've vacillated between strictly
setting all recordsets to Nothing and not bothering.

Can you give me your best case for it NOT being necessary? A lot of the PCs
that run my app only have 128 MB memory, so I am somewhat concerned about
the potential for any memory leaks.
Darryl Kerkeslager
Power corrupts.
Absolute power corrupts absolutely.
Knowledge is power.
See: www.adcritic.com/interactive/view.php?id=5927

Nov 13 '05 #2
Darryl Kerkeslager wrote:
"Lyle Fairfield" <Lo******@FFDBA.Com> wrote

MS examples show setting r and s to nothing. I know of no reason to set
anything except DAO objects to nothing, but maybe you would like to do
this.


Lyle,

I'm definitely going to save your FTP code for later - no use today, but
tomorrow who knows - but I am interested now in the quoted part. Most ADO
code read sets the Recordset = Nothing; but other things I've read say that
the resources will be returned regardless. I've vacillated between strictly
setting all recordsets to Nothing and not bothering.

Can you give me your best case for it NOT being necessary? A lot of the PCs
that run my app only have 128 MB memory, so I am somewhat concerned about
the potential for any memory leaks.


As I said, TTBOMK, there is no reason whatever to think that VBA does
not look after garbage collection as efficiently as any other
programming language (that is when a variable is no longer reachable -
no variable, object, function whatever refers to it, including the
global object - the memory to which it points is released) EXCEPT for
DAO objects, and I think not all DAO objects, perhaps just the Database
and the Recordset, but since it's a long time since I've used DAO I
could well be wrong here. I haven't set anything to nothing (except in
reused legacy code) for years and I have had zero problems with memory
or ghosts.
Nov 13 '05 #3
Nice one.

I have one client in Baku with a regular 40MB download via FTP from the
States. ATM I use the Windows CLI FTP client driven by a script file and
redirecting output to a text file that my program reads and looks for
errors. This has the effect of a dos box saying "downloading, please
wait..." and sitting there for 1 or 2 hours on a good day (overnight
procedure of course).

I hope this will give me more control over handling errors and retries
and even give the office cleaner something to look at by way of a
progress meter :-)

Thanks.

--
This sig left intentionally blank
Nov 13 '05 #4
Lyle Fairfield wrote:

As I said, TTBOMK, there is no reason whatever to think that VBA does not look after garbage collection as efficiently as any other
programming language (that is when a variable is no longer reachable - no variable, object, function whatever refers to it, including the
global object - the memory to which it points is released) EXCEPT for DAO objects, and I think not all DAO objects, perhaps just the Database and the Recordset, but since it's a long time since I've used DAO I
could well be wrong here. I haven't set anything to nothing (except in reused legacy code) for years and I have had zero problems with memory or ghosts.


For me it's not an issue of whether VBA will release the memory or not.
It's a habit from preventing leaks using other languages. That seems
like a good habit to get into whether or not the language releases the
memory. But I don't mind when other programmers rely on the default
behavior. It's similar to textbox.Value vs. textbox. MS will likely
never change the default but they recommend using .Value in case they
do. BTW, your ADO solution is excellent. I have big plans for using
it.

James A. Fortune

Nov 13 '05 #5
Thanks, Lyle. I think "Set rs = Nothing" occurs about 150 times in my code.
I just would like to be convinced that I can do away with it by some
reliable test. For now, memory being more precious than other resources on
the computers we use, I'll stick with it.

--
Darryl Kerkeslager
Power corrupts.
Absolute power corrupts absolutely.
Knowledge is power.
See www.adcritic.com/interactive/view.php?id=5927
Nov 13 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Phillip Armitage | last post by:
I've spent the better part of two days checking out PHP, javascript and numerous other language sites trying to find what I figure should be be an easy web script page. Essentially what I want is a...
9
by: Karl Irvin | last post by:
Does anyone have an example of an FTP script or module for use with Access 2003. I need to send a file from by computer to my web host from within Access. The from folder may or may not be the...
0
by: Daniel Sélen Secches | last post by:
I found a good class to do a simple FTP. Very good.... I'm posting it with the message, i hope it helps someone ============================================================== Imports...
5
by: JGPa | last post by:
In VB 6.0 I could upload a local file to the mainframe and specify in the VB statement both the local file name and the name to assign to the file when it was created on the mainframe. Can I do...
3
by: Greg Sabino Mullane | last post by:
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 A bad link in the ftp source directory inspired me to check the rest of it out: * Main README file needs updating. The URL is given as: ...
9
by: craig.overton | last post by:
All, I am currently developing an FTP class in VB.NET. It's kid tested, mother approved when trying to access an FTP Server on a Windows box meaning I can connect, run commands, upload and...
1
FTP
by: Jim Heavey | last post by:
I am trying to figure out how to use the FtpWebRequest class in .Net (2.0) to transfer a file from a server to my workstation. It is failing to log into the server. When I use the FTP client...
7
by: clintonG | last post by:
I'm puzzled and don't think this is possible but if an application that is running on websiteA generates a file can FTP be used from websiteA to transfer that file to websiteB which would be...
0
by: Holly | last post by:
I copied this code that works to connect into Unix. I am looking for a way to get it to work with a secure Unix box. Anyone have any insights on how to do this? I am trying to build an sftp...
8
by: lawrence k | last post by:
I have to parse some FTP logs, which are full of several thousand lines like this: Thu Sep 4 11:39:04 2008 FTP command: Client "74.231.146.2", "TYPE A" Thu Sep 4 11:39:04 2008 FTP...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.