Data Portability Question!

Knight Stalker
04-19-2004, 06:20 PM
Hi Everyone,

I am having problem with my code, I have an Access database and I use ADO data control to access it. My problem here is that I have to make it "portable" as they have said coz I dont really know the right term to use for it. But what I want to do is to make my database accessible even when I change the location of the program. Like for example I have started making programs in my PC, and when I transferred it in another PC in another Drive, it should work as it is in my PC. please any Help will do I am just really messed up here.

Thanxxx.

webbone
04-19-2004, 06:54 PM
I believe what you are asking is how you can code the path of your database into your application, regardless of where the application resides. Depending on your requirements there are several ways you may need to do this.

If you can install your application on a target PC and have the .mdb file live in the same directory as the application, you can use App.Path when generating your connection string:

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

MKoslof
04-19-2004, 06:54 PM
You could use App.Path. Then your database needs to be in the same directory as your VB application...it eliminates the need to use a hard-coded path. And for better flexibility, you should ditch the data controls and use straight ADO connection and recordset objects.

Or, you could store your database location in an ini file and reference this ini file at run-time to resolve the location of the database.

Knight Stalker
04-19-2004, 07:19 PM
I believe what you are asking is how you can code the path of your database into your application, regardless of where the application resides. Depending on your requirements there are several ways you may need to do this.

If you can install your application on a target PC and have the .mdb file live in the same directory as the application, you can use App.Path when generating your connection string:

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



I have done this and deletes the connectionstring property in the properties box but it generates a database error. Is there any other way around to do do this? and Thank you again.

webbone
04-19-2004, 07:23 PM
Where are you getting the error? Can you post your code so we can better help you with this?

As MKoslof mentioned, it is highly advised to not use the ADODC and to use straight ADO connection and recordset objects. You can find an introductory tutorial on ADO here: ADO Tutorial (http://www.xtremevbtalk.com/showthread.php?threadid=66994)

Knight Stalker
04-19-2004, 07:24 PM
Is this code the right way to do it?


Private Sub Form_Load()
Adodc1.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Persist Security Info=False;Data Source=" & App.Path & "\MoneyBank.mdb"
End Sub

Knight Stalker
04-19-2004, 07:28 PM
the error is Data source name not found and no default driver specified. I cannot use ADO coz it's our assignment and we are asked to use ADODC and to make it portable and there goes the problem.

webbone
04-19-2004, 07:43 PM
Ok. The code you posted should work if your database exists in the same directory as your application. Is this true?

When you had this working on your computer, you had the Connection and RecordSource properties set in the properties tab for the ADODC? Both of these properties can be set inside your code as I believe you have figured out.

You will need to post the specific section of code where you are getting the error in order for us to help you find a solution to your problem.

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum