Database Development

Updating a Website from Access using VBA and FTP

I have a few personal databases that I’ve developed in which I export files and upload to my website.  When I was using my ISP’s free hosting this was never an issue as I could just select the FTP site saved in My Computer.  Well time has past and my hosting needs changed and I wound up with GoDaddy hosting.  I was soon faced with the reality that a real hosting service was quite different from what I was accustomed to with my free ISP’s web space.  My major problem was my databases were no longer automatically saving the exported files to the web server.  I need a new way of updating a website from Access using VBA and FTP.

 

My first route tried to use Windows ftp.exe, but that does not play nice when passive (PASV) file transfer is required as is the case with GoDaddy.

 

I wanted to be able to click one button within my database to sent the updates to the website.  In this case there were 4 .xml files.  I previously had the code export the xml files to a temp directory so I just needed to find a solution that I could automate the upload process within Access using VBA.  Thanks to my dear friend, Google, I found NcFTP, a command-line FTP utility, which can be automated in the same way as Windows’ ftp.exe.  In my case this worked perfectly with my database and GoDaddy hosting.

 

The first step is to download and install the NcFTP Client (direct download)

Then head back to Microsoft Access and modify your VBA code.  My code begins by exporting the 4 .xml files to a temp directory.  I had a choice, I could tell NcFTP to upload each file or upload all files in a directory.  I choose the later as I wanted my entire website’s data to updated each time there is a change in the database.

Here is the VBA code I used:

Shell “ncftpput -u [USERNAME] -p [PASSWORD] [FTP.SITENAME.COM] [RemoteDestinationFolder] [LocalFile2Upload]“, vbNormalFocus

I included vbNormalFocus to show the NcFTP window during the upload process.  This can be hidden, but I prefer to see it working.

 

For the Local file to upload you can specify one file ‘C:\db_temp\filename.xml or a an entire directory C:\db_temp\*

 

Here is an example of how the command line would look if you wanted to upload all files in C:\db_temp to ftp.sitename.com to the remote directory sitename.com/data/

ncftpput -u USERNAME -p PASSWORD FTP.SITENAME.COM data/ C:\db_temp\*

 

There are a few way to implement this code.  For my database I created a table to store my site information less the password.  When the Update website button is clicked the files are exported, the command line is generated and the user is promted from any site credentials not stored in the table.  The files are uploaded from the temp directory.  Finally, the local temp files are deleted.

Access 2010: The Missing Manual

For anyone who has updated from an older version of Microsoft Access and have been overwhelmed by the Office ribbons and new features there is a great book that covers these changes starting right off in the Introduction.   The Access 2010: The Missing Manual is a great read for anyone wanting to get started in Access database development.

What I really like about this book is the author, Matthew MacDonald, doesn’t take the typical teaching approach of showing how to modify the Northwind database as is typical with other Access books.  Instead the book focuses on the fundamentals of Access development.

The Access 2010: The Missing Manual is a much better starting point than the Access Bibles which provide a wealth of information, but can be overwhelming when just starting out.

Microsoft Access 2010 SP1 VBE7.dll Crash Hotfix

For months Microsoft has know and have been working on a fix to a major issue that would immediately crash Access 2010 .  There was a lively discussion started in July on Microsoft’s Answers site.

For months the band aid solution was to decompile the database in question.

  • C:\dbwithissue.accdb  /decompile

This worked just fine, but it was like playing Russian Roulette with your databases.  You could go a day or so without any issue, but the crashes would return without notice.

It was determined the issue was a result of the VBE7.dll included with the SP1 update.  Unfortunately, this dll was used by other Office applications.  Which, I am speculating was the reason why it took so long to get the Hotfix published.

You can read up on the Access 2010 hotfix package (Vbe7-x-none.msp) and request the Hotfix by clicking here.  Below is the warning that accompanies the Hotfix email.

WARNING   This hotfix has not undergone full testing. Therefore, it is intended only for systems or computers that are experiencing the exact problem that is described in the one or more Microsoft Knowledge Base articles that are listed in “KB Article Numbers” field in the table at the end of this e-mail message. If you are not sure whether any special compatibility or installation issues are associated with this hotfix, we encourage you to wait for the next service pack release. The service pack will include a fully tested version of this fix. We understand that it can be difficult to determine whether any compatibility or installation issues are associated with a hotfix. If you want confirmation that this hotfix addresses your specific problem, or if you want to confirm whether any special compatibility or installation issues are associated with this hotfix, support professionals in Customer Support Services can help you with that.

 

Random Contact Generator – Instantly Create Fake Mailing Lists

20110527-071732.jpg

Have you ever had a need for a fake mailing list or contacts to populate a database table during development of your website or database project? I know I do not like to use real names and addresses during development so I developed the Random Contact Generator (RCG), a simple application to do the work for me.

RCG will return First Name, Middle Initial, Last Name, Address, City, State, Zip Code, Phone Number and email address.

RCG offers option to generate logical City State and Zip Code combinations that exist in the United States (Tampa, FL 33601) or generate completely random combinations (Orlando, AZ 90210) for a truly fictitious mailing list.

RCG also offers an option to limit the list by gender or return a random mix of males and females.

If you are interested please visit Random Contact Generator page.


Artisteer - Wordpress Theme Generator Go Daddy Word Press Hosting

Enter your email address to subscribe to this blog and receive notifications of new posts by email.