Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

ADO Data Control Connection string at runtime. 2

Status
Not open for further replies.

ashm01

Programmer
Jun 16, 2003
8
IN
Hello Experts,

I am stuck in a bind here..I have a few ADO Data controls which need a connection string based on the directory the application is installed in..If I have a static directory then it is so problems. However if the directory changes then I got issues.

Why won't this work? I put this in the form load event! What are other avenues..I used the data control because of easy data bindings to data grids.

"Provider=Microsoft.Jet.OLEDB.4.0;Data Source="& app.path &"\DB.mdb;Persist Security Info=False"


HELP

Ashm01
 
Try using the ADODC instead of the old style datacontrol - it has a Connection property that can be set at runtime:

ADODC1.Connectionstring = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source="& app.path &"\DB.mdb;Persist Security Info=False"

________________________________________________________________
If you want to get the best response to a question, please check out FAQ222-2244 first

'People who live in windowed environments shouldn't cast pointers.'
 
That doesn't work..I have the same thing using the

adodc1.connection="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "\DB.mdb;Persist Security Info=False"
adodc1.refresh
adodc1.refresh

First I get a msgbox stating old db not found. and a runtime error..

So no dice Sir..


 
This is a fairly standard situation, so there should be no big problems. Are you using the standard ADODC control? It's Project|Components|MS ADO DataControl (SP4) which is in the MSADODC.OCX file.

Have you updated to VB6 SP5? Download from:

To check that your Jet access is up-to-date goto:
and search for Jet under Access technologies

If you're using a non-Jet db, then get the latest MDAC download

________________________________________________________________
If you want to get the best response to a question, please check out FAQ222-2244 first

'People who live in windowed environments shouldn't cast pointers.'
 
Just try re-arranging your statement.

Give this ago, I have included my declaration to show you what dbCN is.


Private WithEvents dbCN As ADODB.Connection

dbCN.Open "Provider=Microsoft.Jet.OLEDB.4.0;Persist Security Info=False;Data Source= " & App.Path & "\DB.mdb"


I hope this helps,
Regards
Tosh
 
Guys,
I have SP5 loaded with Mdac 2.7
I have the following code in there:

SetupADO.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "\DB.mdb;Persist Security Info=False"
SetupADO.RecordSource = "SetupInfo"
SetupADO.Refresh

As soon as I run it..I get "Could not file find C:\xxxxxxxxx", I have the file in the app directory but, no dice.

I am sure someone out there has managed to have a dynamic connection string at runtime with an ADO Data control to work sucessfully.

Ashm01
 

Remove the Connection string in the DC's property Window.
The rest looks "fine" for this part.
 
Thanx a million, That did the trick...
Awesome, Solved my problems.

ASHM01
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top