Link to home
Start Free TrialLog in
Avatar of Anton Greffrath
Anton GreffrathFlag for South Africa

asked on

MS Acess 2013 for HTTP Get and Post

I am busy with development that link my MS Access 2013 database to GET data from the SQL Server as well as POST data to the SQL Server.
I am aware of the 'HTTP Get' and 'HTTP Post' functions and would like to know where I can get reading material on these two functions that explains all the parameters for MS Access specifically. Also some logical diagrams that show data flow.
Any help is appreciated. . . . .
Avatar of Gustav Brock
Gustav Brock
Flag of Denmark image

SQL Server is not a web server.

In Access, go to External Data and select ODBC database. Set up a connection to the server and link/attach the tables/views you need. Lots of tutorials on this for the browsing.

/gustav
I use Pass-Through Queries with Access and SQL Server.  You can Link the tables as gustav posted or you can include the Connection String in the query Property "ODBC Connect Str"  as shown below...

ODBC;Driver={SQL Server};Server=xxx.xx.xxx.x;Database=YourDBName;User=YourUserName;Password=YourPassword;

Open in new window


Then, just run your queries in your Access front-end.

ET
Avatar of Anton Greffrath

ASKER

Thanks Gustav and Etsherman. . . . . . .

Apologies, I did not give you the full picture. The SQL Server export the data do a folder and I need to 'Get' the data from this position, external to the SLQ Database.
<<<<<Apologies, I did not give you the full picture. The SQL Server export the data do a folder and I need to 'Get' the data from this position, external to the SLQ Database. >>>>>

What format is the data in that you want to import into Access???

ET
And how can get to that file? Is it on a file server you have access to, or is it hosted by a web or ftp server?

/gustav
Gustav

The file is in CSV format as supplied  from the SQL Database. I have access to the file location via:
http://cosmo.co.au/CSV/GetClients, where GetClients is the CSV File
Then the simple method is to download the file to a folder your application has access to and import it from there.

To retrieve the file, use a function like this:
Option Compare Database
Option Explicit

Private Declare Function URLDownloadToFile Lib "urlmon" Alias "URLDownloadToFileA" ( _
    ByVal pCaller As Long, _
    ByVal szURL As String, _
    ByVal szFileName As String, _
    ByVal dwReserved As Long, _
    ByVal lpfnCB As Long) _
    As Long


Public Function DownloadFile( _
    ByVal strURL As String, _
    ByVal strLocalFilename As String) _
    As Long
  
' Download file or page with public access from the web.
' 2004-12-17. Cactus Data ApS, CPH.

' Usage, download a file:
' lngRet = DownloadFile("http://www.databaseadvisors.com/Graphics/conf2002/2002ConferencePicsbySmolin/images/dba02smolin27.jpg", "c:\happybassett.jpg")
'
' Usage, download a page:
' lngRet = DownloadFile("http://www.databaseadvisors.com/conf2002/conf200202.asp", "c:\dbaconference.htm")

' Returns 0 if success, error code if not.
' Error codes:
' -2146697210 "file not found".
' -2146697211 "domain not found".

' Limitation.
' Does not check if local file was created successfully.

    Dim lngRetVal As Long
      
    lngRetVal = URLDownloadToFile(0, strURL & vbNullChar, strLocalFilename & vbNullChar, 0, 0)
    
    DownloadFile = lngRetVal
  
End Function

Open in new window

/gustav
<<<<<The file is in CSV format as supplied  from the SQL Database.>>>>>

Download the file ... Then use the Import Wizard in Access to import a Text file as shown below.  You can click the Advanced button and create an Import Spec for your file.

ET

User generated image
Thanks Gustav and Etsherman, great answer and quick response! I have implemented your suggestions and it works like a dream.

I still require some reading material on the subject, do you perhaps have a link to such material? it was nice implementing the solution but I would like to have an understanding of the subject. . . .

Many thanks again

PetranAnton
I've requested that this question be closed as follows:

Accepted answer: 0 points for PetranAnton's comment #a41164284

for the following reason:

I could implement the code, with minor changes to fit my environment, and it worked the first time.
Great. Then mark the solutions as answers.

You can bing/google on the API call URLDownloadToFile.

For the file import, use the help from Access itself.

/gustav
ASKER CERTIFIED SOLUTION
Avatar of Eric Sherman
Eric Sherman
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Quick Response and to the point. . .
ET, I am new to this User Group, Am I involved in allocating points for this solution?
Thank you for - eh - nothing ...

/gustav