setting adodc database location runtime 
Author Message
 setting adodc database location runtime

I'm making this application using the adodc with VB6 SP4, and
everything is working just fine. That is, as long as the Access 2000
database is located as specified design time. That will not be the
case in the user environment, however.

When trying to set another location in the form_load of the adodc's
parent form, the app is first displaying a series of error messages
because it can't find anything at the design time specified location
(I've moved the database). Thereafter it's behaving just fine. Seems
to me the adodc is trying to connect _before_ my form_load code is
executed.

What I want to do is to specify the database location runtime, which I
tried to do by simply changing the adodc.connectionstring in
form_load. If that's not the proper way of doing it, what is?

If I try the same thing without any design time specifications it also
displays a series of error messages, but only for some of the adodc's
(there are several). Some seems to be working like I expect them to.
Problem is, I can't tell the difference between them. Even tried
replacing one of them with a copy of another, just changing it's name
and still got different behaviour.

This is kind of frustrating.
Thanks in advance for any help.

- Bernhard



Wed, 27 Aug 2003 07:08:20 GMT  
 setting adodc database location runtime
Bernhard

You can do it like this:

For each Adodc control in the Properties delete the ConnectionString and
RecordSource and set the CommandType to 8 - adCmdUnknown, you can leave the
LockType & Mode as is

Then do this in the Form_Load()

Dim strCN As String
Dim strRecSource As String
strCN = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path &
"\MDBName.mdb"
strRecSource = "<sql string or table/query name>"
With Adodc1
    .CommandType = 1 ' for sql string, 2 for table/query
    .ConnectionString = strCN
    .RecordSource = strRecSource
    .Refresh
End With
'
'now set the datafield and refresh any dependent data controls, e.g.
FlexGrid/DataCombo/List etc.

regards

Ian

** invalid email address, change dk to denmark

homepage http://www.kingsoft-denmark.com/
Tips & Tricks page http://tips.kingsoft-denmark.com/


Quote:
> I'm making this application using the adodc with VB6 SP4, and
> everything is working just fine. That is, as long as the Access 2000
> database is located as specified design time. That will not be the
> case in the user environment, however.

> When trying to set another location in the form_load of the adodc's
> parent form, the app is first displaying a series of error messages
> because it can't find anything at the design time specified location
> (I've moved the database). Thereafter it's behaving just fine. Seems
> to me the adodc is trying to connect _before_ my form_load code is
> executed.

> What I want to do is to specify the database location runtime, which I
> tried to do by simply changing the adodc.connectionstring in
> form_load. If that's not the proper way of doing it, what is?

> If I try the same thing without any design time specifications it also
> displays a series of error messages, but only for some of the adodc's
> (there are several). Some seems to be working like I expect them to.
> Problem is, I can't tell the difference between them. Even tried
> replacing one of them with a copy of another, just changing it's name
> and still got different behaviour.

> This is kind of frustrating.
> Thanks in advance for any help.

> - Bernhard



Wed, 27 Aug 2003 07:47:59 GMT  
 setting adodc database location runtime

Quote:
> For each Adodc [...] set the CommandType to 8 - adCmdUnknown,

With exception for setting CommandType to 8, that's about exactly what
I did in the first place. (Done that now.)

Quote:
> Then do this in the Form_Load() [...]

Did that too. But I still got an error message for one of my adodc's.

Quote:
> 'now set the datafield and refresh any dependent data controls, e.g.

This, however, was the clue solving my problem. Seems like my code was
OK, except for the fact that one bound textbox on change called
procedures wanting data from another adodc with location not yet set.
That in turn caused it to "behave differently" compared to the others.
Not binding that one to its datafield designtime solved it.

Thanks a lot!

- Bernhard



Wed, 27 Aug 2003 20:16:06 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. Setting database location at runtime

2. Setting Crystal Report Database Location at RunTime...

3. ???URGENT!!! Set Database Location in Runtime

4. Problems setting database location at runtime.

5. Setting properties for ADODC during runtime...

6. HOW DO I Set ADODC Connection at Runtime?

7. Crystal 4.6 set database location - same as database

8. Please, Can an ADODC be set at runtime?

9. Need Help: Setting ADODC control ConnectString at Runtime

10. Setting ADODC control's datasource at runtime

11. setting adodc cnxn string @ runtime

12. adodc - setting connectstring at runtime

 

 
Powered by phpBB® Forum Software