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 TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

path to database with ADODC

Status
Not open for further replies.

rs51

Technical User
Oct 13, 2001
163
PT
hi
i'd like to have the path to my database something like this:
app.path + "mydatabase.mdb" .
That because i'd like the install package to have the database in the same directory as everything else, and dont want the client to build several folders to put the database in,i.e.: c.//my docs/my app/mydatabase.mdb
I thing this can be made if instead of adodc i use code, but hot to achieve it with adodc?
thanks in advance
 
Go into ADODC properties and copy the connection string.
In your Form_Load event (or wherever) use:

Code:
ADODC1.Connection string =

then paste. Edit that to remove the path bit so:
Code:
"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=F:\Program Files\Microsoft Visual Studio\VB98\BIBLIO.MDB;Persist Security Info=False"

becomes
Code:
"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & app.path & "\BIBLIO.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.'
 
hi again
That's great!
thanks a lot
works perfectly!
 
Ooops
so sorry
i made a mistake: to check if it worked, i made as you said, but forgot to move the database!
So, when i took it away, lots of errors saying missing database pop-up...
so, i'm still in the dark
I also changed code like this:
i has this:
cs = "provider=microsoft.jet.oledb.4.0; data source =c:\os meus documentos\as minhas turmas\a.mdb"
and changed to this:
"provider=microsoft.jet.oledb.4.0; data source =" & App.Path & "\a.MDB;"
this didnt worked, so i changed to this:
"provider=microsoft.jet.oledb.4.0; data source =" & App.Path & "\a.MDB;Persist Security Info=False"

So, what am i missing?
thanks again
 

This is exactly what you asked for:
That the database is in the same directory as the application EXE or Vbp.
Make sure it is there.

Do this to verify the connection string:

In the Immediate/Debug window type:
?"provider=microsoft.jet.oledb.4.0; data source =" & App.Path & "\a.MDB;Persist Security Info=False"

It should show you when it is looking for the Mdb...In the application path.
[/b][/i][/u]*******************************************************
General remarks:
If this post contains any suggestions for the use or distribution of code, components or files of any sort, it is still your responsibility to assure that you have the proper license and distribution rights to do so!
 
wherever i've a connection string i put
"provider=microsoft.jet.oledb.4.0; data source =" & App.Path & "\a.mdb;Persist Security Info=False";

i also have in form_load the following for every adodc:
Adodc1.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "\a.mdb;Persist Security Info=False"

i do have the database in the same folder of vb project;

my question now is: What do i put in the connectionstring, in the properties window, of each adodc i have?

i tried several things, but didnt work at all: i left it blank, i tried app.path, and so on.

Can you please help?
thanks in advance
 
When you run the program your line:
Adodc1.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "\a.mdb;Persist Security Info=False"
will update whatever is currently in the Connection string property.

If you just leave the unedited version in the properties box then intellisense will still work for you at design time.
________________________________________________________________
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.'
 
hi
thanks for helping

i left the properties window's connectionstring pointing to the database that's in the same path as the .exe and vbp.
But its too late and cant check the installer in another machine; tomorrow i'll see if it works

thanks again
 
After all i tried again, but...
i left the path to the database in the windows property's adodc, and used the app path in the form load and in the connections strings. I made the install and when i install in another machine, i get this message:
"an error ocurred while registering the file 'C:\WINDOWS\system32\msado.tlb'
what's happening?
 
You should really start a new thread for a new question, but try:
________________________________________________________________
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.'
 
thanks for helping
your link solved my last problem, but, as i feared, when the install is complete, the program claims the following:
"C:\documents and settings\ and So On\...\a.mdb is not a valid path. Make sure that the path name is spelled correctly and that you are connected to the server in which the file resides."
This means two things: now i need the database in the same folder of the installation - otherwise the program asks for the database there - and the replication of the path to the database similar to which i have in my working files (along with the database).
Looks like that, in one hand, the app path has to have the database in the same folder of the rest, and, in the other hand, as the connectionstring in the windows properties's ADODC points to another location, the client has to have that location too. Dont know how to work this out...
Can you help please?
 
app.path means just that! It's the path that the application is running from.

On the client machine the db should also be in the same folder as the app.

If you refer back to your original question, that's what you asked!

For any further info on this I suggest a visit to VBHelp, looking for the App Object
________________________________________________________________
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.'
 
hi again
now i know how to do it.
first, eliminate from adodc properties the recordsource too; then:

Private Sub Form_Load()

Adodc1.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "\a.mdb;Persist Security Info=False"

Adodc1.RecordSource = "Select * from Table1"
Adodc1.Refresh

End Sub

and worked
thanks everybody who helped me
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top