I am using a Data Environment to create a data report. The code is working fine in one app, but after I copy-pasted it to another app, it's giving problem. Both apps are similar and have same references and in same sequence


This works fine (in App # 1)

Dim mFileName As String
    mFileName = App.Path & "\IrisRep.mdb"
    If DEnv.Conn.State = adStateOpen Then
        DEnv.Conn.Close
    End If
    DEnv.Conn.ConnectionString = "Provider=MSDataShape.1;" & _
        "Persist Security Info=False;" & _
        "Data Source=" & mFileName & ";" & _
        "Data Provider=Microsoft.Jet.OLEDB.4.0"
    DEnv.Conn.Open

Internally the Connection string is

Provider=MSDataShape.1;Persist Security Info=False;Data Source=C:\Projects\Iris\IrisRep.mdb;Data Provider=Microsoft.Jet.OLEDB.4.0

In App # 2, it's the same code

Dim mFileName As String
    mFileName = App.Path & "\IrisRep.mdb"
    If DEnv.Conn.State = adStateOpen Then
        DEnv.Conn.Close
    End If
    
    DEnv.Conn.ConnectionString = "Provider=MSDataShape.1;" & _
       "Persist Security Info=False;" & _
        "Data Source=" & mFileName & ";" & _
        "Data Provider=Microsoft.Jet.OLEDB.4.0"
    
    DEnv.Conn.Open

Now the connection string is getting changed to

Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Projects\WomCollge\IrisRep.mdb;Extended Properties="Data Provider=Microsoft.Jet.OLEDB.4.0";Persist Security Info=False

As you can see, the provider is getting changed and the Extended Properties stuff is coming in. This changes are happening automatically. I found out the connection string by setting a breakpoint and checking in the debug window.

Naturally the connection and report are not coming. I am getting a dialog box to select Jet Ole DB parameters and then a "Could not find Installable ISAM" error

My question is : How do I stop the connection string from getting changed ?

Your connection string seems fine as long as you refer to "App.Path" and then the .mdb.

Ensure that the database was installed in the correct path i.e. - C:\Projects\WomCollge\. Also ensure that your data objects was installed and referenced correctly on the user machine, the ISAM part of error. If no data objects is installed "MDAC", then you will get errors.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.