Dear,programer

I use VB2008 and database access and Crystal report.
my problem : when ever I change location the database. I will always change location in my report from crystal report. It's very difficults and waste the time because I have many report.
Please help me how to set up location only 1 place and impact to many report.

My VB Code :
Dim dbname1 As String = "D:\AF_Software\DB\DBAF1.mdb"
Public Strcon As String = "Provider=microsoft.jet.oledb.4.0;data source=" & dbname1 & ";jet OLEDB:Database Password=999"

Please help me to make code in crystal report , if i want change drive to drive Z / or somthing else.
now, i am go to the report and click change location.

Thank you,

When ur application starts for the very first time allow the user to save the database location in a particular text file....

for that u have to give the openfiledialog box that will take the file location and save the location....

so that during the connection u can get the database path details from the text file itself....

the next time onwards the user shud only check if the filename is present in ur textfile...if the textfile is empty or the database is invalid it shud prompt the user with error msg and again ask to relocate the database...

if its not clear do post again...will help u further...

If you are using a stand-alone application you can always keep the database in your application path (where the exe resides).
What makes you to change the database location often? Include or create the database in the application path.

Never hardcode any path in your code ("D:\AF_Software\DB\DBAF1.mdb"). Use relative path instead for accessing database and files (App.Path & "\DB\DBAF1.mdb").

If your database name or its password change time to time then go with poojavb.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.