changing data environment datalink properties in code

Posted on 2006-06-01
Last Modified: 2010-04-30
I am developing a VB6.0 app linked to an MS Jet/Access database on my machine.  Oviously the app will be distributed to my clients upon completion.  In the data enviroment, on the 'connection' tab of the datalink properties I enter the path where the MDB is located on my development machine, 'C:\TestApp\Client.MDB'.  This works great for testing but when I let the client install the app they do not have to use the same directory strcuture or even drive letters that I use in testing.

When the app is distributed how do I alter the 'connection' tab property to point to the production MDB.  The MDB may be in another directory that the one I tested with and will most likely be on a network drive rather than C:.

I am making some adhoc connections to the database using the following:

  dbName = "NEIntAndWeb.mdb"
  Open_Ini    'loads 'networkPath' based on values in the .ini
  strConnect = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & NetworkPath & dbName

can I overlay the Data Environment connection with 'strConnect'
Question by:mlcktmguy
    LVL 5

    Accepted Solution

    What I have is on the start up form (could be a login form) there will be a browse button to set the path to where the db reside.

    Any where I make the connection, I use the path that the client provided. You seemed to be on the right path so what’s wrong?
    LVL 1

    Author Comment

    How to I overlay the dataenvironment connection set up in development mode to the correct connection in production mode?  The name of the data environment is DataEnvironment1, the connection is Connection1.
    LVL 1

    Author Comment

    Got it:

    DataEnvironment1.Connection1.ConnectionString = strConnect

    Featured Post

    IT, Stop Being Called Into Every Meeting

    Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

    Join & Write a Comment

    Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
    Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
    Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
    This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

    730 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

    15 Experts available now in Live!

    Get 1:1 Help Now