To ErlandSommarskog
Hi,
I have an Access database built to capture data from a remote database (SQL Server or any other) at an anonymous customer. To test its possibility, I used the following Access subroutine to capture data on a SQL Server database located on the same machine:
Sub CaptureData()
Dim url As String, filePath As String, attempts As Integer
Dim WinHttpReq As Object, oStream As Object
url = "http://MyPublicIP\DESKTOP-0EKQG3O\SQLEXPRESS,1433/sosdata/cargo/brooker")
filePath = "c:\sos\SQLServerExtract.txt"
attempts = 3
Set WinHttpReq = CreateObject("MSXML2.XMLHTTP.6.0")
On Error GoTo TryAgain
TryAgain:
attempts = attempts - 1
Err.Clear
If attempts > 0 Then
WinHttpReq.Open "GET", url, False
WinHttpReq.Send
url = WinHttpReq.ResponseBody
If WinHttpReq.Status = 200 Then
Set oStream = CreateObject("ADODB.Stream")
oStream.Open
oStream.Type = 1
oStream.Write WinHttpReq.ResponseBody
oStream.SaveToFile filePath, 2 ' 1 = no overwrite, 2 = overwrite
oStream.Close
End If
Else
MsgBox ("A4. No internet connection is available.")
End If
End Sub
The captured data is then inserted in the Access database. If SQL Server does not speak HTTP as you said, then the above-mentioned subroutine cannot be used. Does this apply to all DBMS? Please advise what sort of API I may use to do the same function within Access, other than ODBC because table structures may not be the same. If API within Access is not possible, what the customer should do so that I can connect to his DBMS via HTTP?
Regards.