Solved

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

Posted on 2002-07-26
7
325 Views
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.
0
Comment
Question by:john_vimal
7 Comments
 
LVL 4

Expert Comment

by:Glowman
Comment Utility
John,

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.

G
0
 
LVL 10

Expert Comment

by:aeklund
Comment Utility
Can you show us the code in which you are removing and settings the connection string?
0
 
LVL 2

Expert Comment

by:yongyih
Comment Utility
May be you need to set the connection string in form_load and set it to your control. ^_^

good luck.
0
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
LVL 75

Expert Comment

by:Anthony Perkins
Comment Utility
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.

Anthony
0
 
LVL 2

Accepted Solution

by:
ventond earned 100 total points
Comment Utility
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.
0
 
LVL 16

Expert Comment

by:twalgrave
Comment Utility
PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!

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.
0
 

Author Comment

by:john_vimal
Comment Utility
thanks for your help mate
0

Featured Post

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
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…

743 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

18 Experts available now in Live!

Get 1:1 Help Now