How to specify the connection string of an ADODC control at runtime.

Posted on 2002-07-26
Last Modified: 2010-05-02
I want an ADODC which has to connect to a different location(database,username and password).

Now when i specify the connection string at design time the databinding of the other controls seem to work fine. Now when i remove the connectionstring from the design time settings and then set the connection string of the ADODC control at run-time, the ADODC gives an error of 'Object Required' when any reference to the underlying recordset is made.

It will be great if someone has a solution for the same.
Many thanks in advance as it is a matter of urgency.
Question by:john_vimal
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

Expert Comment

ID: 7180149

I am not sure but it seems that your controls are trying to initialize before your suppling the connection string.  You could try to give your app the connection string sooner in your code like in the form initialize event perhaps.

LVL 10

Expert Comment

ID: 7180157
Can you show us the code in which you are removing and settings the connection string?

Expert Comment

ID: 7180233
May be you need to set the connection string in form_load and set it to your control. ^_^

good luck.
Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

LVL 75

Expert Comment

by:Anthony Perkins
ID: 7180453
Actually you need to set it before you Show the form.  In other words make Main() in a .bas module the startup object and initialize the Data Control to the connection string here, than do a Refresh and finally Show the form.

Having said this, you may want to re-consider using the Data Control in the first place as they are typically more trouble than they are worth.  Most developers use them once in a major app and never again.


Accepted Solution

ventond earned 100 total points
ID: 7180693
If you change a data controls connection string at run time (after it has already opened), you must tell the data control to reconnect. (Re Open). Or, better solution, don't have it set in design time at all.

Set it in design time, use the retrieve fields of your other controls, then unset it. That way the data control will never have established the first connection string before you change it, and you won't have to Re-open the control.
LVL 16

Expert Comment

ID: 7652557

No comment has been added lately, so it's time to clean up this TA.
I will leave a recommendation in Community Support that this question is:
- points to Glowman
Please leave any comments here within the
next seven days.

Author Comment

ID: 7654234
thanks for your help mate

Featured Post

Salesforce Has Never Been Easier

Improve and reinforce salesforce training & adoption using WalkMe's digital adoption platform. Start saving on costly employee training by creating fast intuitive Walk-Thrus for Salesforce. Claim your Free Account Now

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Using "ScreenUpdating" 6 85
Sending a email via excel using vba 6 117
How to read File Date Created using VB6 8 70
adding "ungroup sheets" to existing vbs code 5 75
Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…

732 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