Solved

Using JRO in VB.Net

Posted on 2004-08-20
10
1,630 Views
Last Modified: 2012-05-05
Hi,
  Is it possible for me to use JRO in VB.Net?? I have tried the following synchrnization code and some how it is not working:

 Public Function synchDB(ByVal mainDB As String, ByVal secondDB As String)
        Dim jrB As JRO.Replica

        jrB = New JRO.Replica
        Try
            jrB.ActiveConnection = mainDB

            jrB.Synchronize(secondDB, JRO.SyncTypeEnum.jrSyncTypeImpExp,
                                    & JRO.SyncModeEnum.jrSyncModeDirect)

            jrB = Nothing
        Catch ex As Exception
            MsgBox(ex.Message)
        End Try
    End Function

This is how I call the function out:

synchDB(CStr(Application.StartupPath & "\Branch.mdb"), CStr(Application.StartupPath
                     & "\tempDB.mdb"))

when the code reach the execution of "jrB.ActiveConnection = mainDB" it shows error which I am not quite sure how to solve. It shows the following error message:

"Arguments are of wrong type, are out of acceptable range, or are in conflict with one another"

Can anyone tell me what's the reason for the error message?? Show me how to solve it please. Thanks

0
Comment
Question by:JohnWoo
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
10 Comments
 

Expert Comment

by:rpter
ID: 11855615
Hi,

This should work;

    Public Function synchDB(ByVal mainDB As String, ByVal secondDB As String) As Boolean

        'Create an instance of Replica object
        Dim dbRep As New JRO.Replica

        ' Connection
        Dim strConn As String = "Provider=Microsoft.JET.OLEDB.4.0;Data Source = " & mainDB

        ' use a try statement as we'd get an error if it is already replicable
        Try
            dbRep.MakeReplicable(mainDB, True)
        Catch
        End Try

        Try
            ' Call CreateReplica method to create replica of the database
            dbRep.CreateReplica(secondDB, "Replica of Database", jrRepTypeFull)
        Catch ex As Exception
            MsgBox(ex.Message)
            Return False
        End Try

        Return True

    End Function


Roland
0
 
LVL 4

Expert Comment

by:Daniellus83
ID: 11855681
Maybe this helps you (a few examples I found):   Use ADO.NET!

'===============================================================================
' Desc : Compact a database (MDB)
' Param :
'        dbPathAndName : The path and name of the DB to compact. If nothing is
'                        set for this variable, the system will take the current
'                        DB (set in GetDBInfo)
'        MakeBackup    : If its true make a copy of the DB
' Return: <nothing>
'===============================================================================
Public Sub CompactDatabase(Optional dbPathAndName As String, Optional MakeBackup As Boolean)
    Dim JRO As New JRO.JetEngine
    If dbPathAndName <> "" Then
        If MakeBackup Then Call FileCopy(dbPathAndName, dbPathAndName & ".bak")
        JRO.CompactDatabase "Provider=Microsoft.Jet.OLEDB.4.0;" & _
                            "Data Source=" & dbPathAndName, _
                            "Provider=Microsoft.Jet.OLEDB.4.0;" & _
                            "Data Source=" & App.Path & "\dtnetCompact.mdb;" & _
                            "Jet OLEDB:Engine Type=4"
        Call Kill(dbPathAndName)
        Name App.Path & "\BakCompact.mdb" As dbPathAndName
    Else
        Call GetDBInfo
        If MakeBackup Then Call FileCopy(dbPath & dbFileName, dbPath & dbFileName & ".bak")
        JRO.CompactDatabase "Provider=Microsoft.Jet.OLEDB.4.0;" & _
                            "Data Source=" & dbPath & dbFileName, _
                            "Provider=Microsoft.Jet.OLEDB.4.0;" & _
                            "Data Source=" & App.Path & "\dtnetCompact.mdb;" & _
                            "Jet OLEDB:Engine Type=4"
        Call Kill(dbPath & dbFileName)
        Name dbPath & "\BakCompact.mdb" As dbPath & dbFileName
    End If
    Set JRO = Nothing
End Sub

--------------------------------------------------------------------------------------------------------------------------------------------------------

On this URL (http://www.codeproject.com/books/186100558x_16.asp) I found this text:

JRO In Managed Applications
ADO.NET does not provide direct support for features such as compacting a database, database replication, replica synchronization, setting passwords, and encryption on databases, and so on. These features are available in the classic ADO model through Jet and Replication Objects (JRO). An application can provide all these features by using Interop to access JRO objects....
----------------------------------------------------------------------------------------------------------------------------------------------------------------------

0
 
LVL 2

Author Comment

by:JohnWoo
ID: 11879317
hmmm................good link but are the methods you proposed could synchronized 2 replicated Access databases?? My situation is I am trying to synchronize 2 replicated access databases with coding.
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 

Expert Comment

by:rpter
ID: 11879947
did you try my sample? that should do it...
0
 
LVL 2

Author Comment

by:JohnWoo
ID: 11883890
I have tried it but that only allow me to replicate database, not synchronizing them.
0
 

Accepted Solution

by:
rpter earned 100 total points
ID: 11887659
ah, sorry.
Had a quick look and i see the problem. The only way i can think of to get round it is to use COM interop to use a vb6 component to access it either directly or indirectly. A quick search on the net led me here
http://www.trigeminal.com/replication/synch.asp?1033 
maybe this will allow you to do it (although i havent tried it)

Roland
0
 
LVL 2

Author Comment

by:JohnWoo
ID: 11899653
ok...thanks......let me try and see first.
0
 
LVL 3

Expert Comment

by:kmcbrearty
ID: 13952870
JohnWoo,

I don't know if you are still trying to find the answer on this or not.  I posted the same exact question and was able to determine the problem.  You can view the following question to see how to resolve it:

http://www.experts-exchange.com/Programming/Programming_Languages/Dot_Net/VB_DOT_NET/Q_21414739.html

Basically you need to create an ADODB connection and pass that to the ActiveConnection Property.

Thank you,
Kevin McBrearty
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

If you're writing a .NET application to connect to an Access .mdb database and use pre-existing queries that require parameters, you've come to the right place! Let's say the pre-existing query(qryCust) in Access takes a Date as a parameter and l…
Introduction As chip makers focus on adding processor cores over increasing clock speed, developers need to utilize the features of modern CPUs.  One of the ways we can do this is by implementing parallel algorithms in our software.   One recent…
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…

623 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