473,324 Members | 2,356 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,324 software developers and data experts.

Get text data from web

I need to get some data off the web for my database.
I tried
DoCmd.TransferText acImportDelim, "WebData", "WebData", "http://www.mywebsite.com/test.txt", False
but it doesn't work
May 10 '11 #1

✓ answered by Chris Arc

I got this code to work very well

Expand|Select|Wrap|Line Numbers
  1. Private Declare Function URLDownloadToFile Lib "urlmon" _
  2.     Alias "URLDownloadToFileA" (ByVal pCaller As Long, _
  3.     ByVal szURL As String, ByVal szFileName As String, _
  4.     ByVal dwReserved As Long, ByVal lpfnCB As Long) As Long
  5.  
  6.  
  7.     ' Download the file.
  8.     URLDownloadToFile 0, _
  9.         "http://www.mywebsite.com/data/test.txt", _
  10.         "c:\temp\text.txt", 0, 0
  11. DoCmd.TransferText acImportDelim, "WebData", "WebData", "c:\temp\text.txt", False

3 2938
NeoPa
32,556 Expert Mod 16PB
You're not dealing with a browser, so I would lose the "http://" from the name of the file.

The Help isn't very specific about what it can handle in that parameter (FieldName by the way) so it's not clear whether that format is supported. If not, I expect you'll need to transfer the file to a temporary location first.
May 10 '11 #2
I got this code to work very well

Expand|Select|Wrap|Line Numbers
  1. Private Declare Function URLDownloadToFile Lib "urlmon" _
  2.     Alias "URLDownloadToFileA" (ByVal pCaller As Long, _
  3.     ByVal szURL As String, ByVal szFileName As String, _
  4.     ByVal dwReserved As Long, ByVal lpfnCB As Long) As Long
  5.  
  6.  
  7.     ' Download the file.
  8.     URLDownloadToFile 0, _
  9.         "http://www.mywebsite.com/data/test.txt", _
  10.         "c:\temp\text.txt", 0, 0
  11. DoCmd.TransferText acImportDelim, "WebData", "WebData", "c:\temp\text.txt", False
May 20 '11 #3
NeoPa
32,556 Expert Mod 16PB
Perfect Chris :-)

I would suggest adding a line of code to run at the end of what you've posted to delete the temporary file if that seems appropriate to you.
May 20 '11 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

9
by: Stephen Saunders | last post by:
Hey Folks, This one currently has me stumped. I have to check for the existence of a carriage return (Enter key, hex 0D) in text data. First I tried: 'Check comment to not contain the CR...
2
by: leegold2 | last post by:
General DB questions, Why do we use null values? Why is it better than an empty field? What would be a real life situation were nulls are important to have? If I have a paragraph of text in a...
5
by: adrian | last post by:
hi all this is my first post to this group, so pls bear with me while i try to make some sense. i am trying to create a sproc which uses dynamic sql to target a particuar table eg. '.' and...
1
by: Ola Theander | last post by:
Dear subscribers I'm currently creating a small application that will run at the end of a web installation to configure a SQL Server. For this task I have a SQL batch file in the same format...
9
by: Susan Bricker | last post by:
Greetings. I am having trouble populating text data that represents data in my table. Here's the setup: There is a People Table (name, address, phone, ...) peopleID = autonumber key There...
6
by: smilly | last post by:
This field is bound to a image data type in SQL server that is used to house big amounts of text how can I output the text data because right now I am getting System.Byte
5
by: sirimanna | last post by:
hello, i'm new to VB...i like to know how to open some text data save in c: in to text box.. i know to save cord's to save data in text box in to c:..but i don't know how to get back that save...
0
by: Jack | last post by:
Hi, I do a webrequest and it returns some text data in a stream. I want to put this tyext data into a string. I've got it working just fine, but I have to put the text data into into a...
6
by: aagarwal8 | last post by:
Hi, I am trying to write the contents of a textbox to a file in binary format. My code looks like this... private void btnWriteToFile_Click(object sender, EventArgs e) { FileStream fs =...
9
by: sillyr | last post by:
Hi - I use Access 2007. I have a two data fields that I would like to add together in a query and then have the query sum the data for the entire table. The problem is that one of the data fields...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

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.