Solved

ADODB Connection to mdb on remote server

Posted on 2011-02-24
4
998 Views
Last Modified: 2012-05-11
Experts,  I would like to enable a function in my Microsoft Access 2003 Database where records from the Local DB Table (PROBLEMLOG) are written to an Access mdb containing the exact same table on a remote http server.

The mdb is accessible at a URL similar to: http://www.myurl.com.au/mydblocation/mydbname.mdb

I'm new to ADODB connection strings and am having trouble working it out.  Please have a look at my code snippet at tell me what I am doing wrong.  

Thanks

Public Function uploadLog()
'Uploads the Problem to the Server based mdb

Dim cn As ADODB.Connection
Dim rsLog As DAO.Recordset
Dim rsWeb As ADODB.Recordset
Dim strSQL As String
Dim strCn As String
Dim myURL As String
Dim fld as field

'Get the local records to be send to the server DB
strSQL = "SELECT * FROM PROBLEMLOG WHERE SendToSupport=False"
Set rsLog = CurrentDb.OpenRecordset(strSQL, dbOpenDynaset)

If rsLog.RecordCount > 0 Then  
'There are some records to send
'Now Make connection to the server side Access 2003 mdb
'***** TROUBLE HERE!  *********    
    Set cn = New ADODB.Connection
    myURL = "//www.myurl.com.au/mydblocation/mydbname.mdb"
    strCn = "Provider=MS Remote; Remote Server=" & myURL _
    & "Remote Provider=Microsoft.Jet.OLEDB.4.0;"
    With cn
        .ConnectionString = strCn
        .CursorLocation = adUseServer
        .OPEN
    End With

'***** I THINK ITS OK FROM HERE ON? ********
'***** BUT CAN'T GET PAST THE CONNECTION BIT TO SEE *****

    'Open the Server Side Recordset for editing
    Set rsWeb = New ADODB.Recordset
    rsWeb.OPEN "SELECT * FROM PROBLEMLOG", cn
    
    'If connection made then continue to write
    rsLog.MoveFirst
    Do Until rsLog.EOF
        rsWeb.AddNew
        For Each fld In rsLog.Fields
            Debug.Print fld.NAME, rsLog(fld.NAME), fld.Type
            rsWeb(fld.NAME) = rsLog(fld.NAME)
        Next fld
        rsWeb.Update

'Edit the local record so that it it does get resend next time
        rsLog.Edit
        rsLog!SentToSupport = True
        rsLog.Update
'move onto the next record 
       rsLog.MoveNext
    Loop
End If
End Function

Open in new window

0
Comment
Question by:Carl Sudholz
  • 2
  • 2
4 Comments
 
LVL 20

Accepted Solution

by:
hes earned 250 total points
ID: 34969950
0
 
LVL 20

Expert Comment

by:hes
ID: 34969951
Sorry cap lock stuck
0
 

Author Closing Comment

by:Carl Sudholz
ID: 34975024
Provide the link to a solution that led me down the right track to solving the problem.

Thanks
0
 

Author Comment

by:Carl Sudholz
ID: 34975063
FYI,  Yep no good having an MDB on the server.  Solution was to:
1. set up a Database on mysql, with tables and user permissions
2. Install the MySQL connector driver (mysql-connector-odbc-5.1.8-win32.msi) from http://dev.mysql.com/downloads/connector/odbc/5.1.html
3. Set the connection string to:

Private Const conString As String = "Provider=MSDASQL;" & _
                                    "DRIVER={MySQL ODBC 5.1 Driver};" & _
                                    "SERVER=127.0.0.1;" & _
                                    "DATABASE=mydbname.mdb;" & _
                                    "UID=systemuser;" & _
                                    "PASSWORD=password1;" & _
                                    "OPTION=3"

From there the function works a treat pretty much as coded in the question.

Cheers
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
In Microsoft Access, learn the trick to repeating sub-report headings at the top of each page. The problem with sub-reports and headings: Add a dummy group to the sub report using the expression =1: Set the “Repeat Section” property of the dummy…
With Microsoft Access, learn how to start a database in different ways and produce different start-up actions allowing you to use a single database to perform multiple tasks. Specify a start-up form through options: Specify an Autoexec macro: Us…

919 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now