Jump to content

Recommended Posts

Posted

Hi :hello:

Im developing a small database software using vb .net by refer to a f:\db.mdb. but after debugging and use the executable file on another machine it aske for the desire datebase with the same old path :}

what to do ?? Please Help ??


Posted

What does the code look like that is calling the database? Do you check if the path exists before loading? Do you have a setting file that keeps the path? Did the file exist on the other computer you were trying to run it on?

If you post part of your code that is giving you issues I might be able to help.

I would do something like the following that way if the hardcoded path is not valid then the user will be prompted to enter a new one if they want to contine.

'hardcoded filename to load
dim path as string = "f:\db.mdb"

private sub btnConnect(sender as system.object, e as eventargs)
 if system.io.file.exists(path) = true then
   me.LoadDb(path)
 else
   dim filename as string = string.empty
   dim ofd as new openfiledialog
   with ofd
     .filter = "access mdb (*.mdb)|*.mdb"
     if .showdialog(me) = dialogresult.ok then
       filename = .filename
     end if
   end with
   ofd.dispose
   me.refresh

   if filename is string.empty then
     'no valid filename selected, exit subroutine
     exit sub
   else
     'valid filename was found so try loading it
     me.LoadDb (filename)
   end if
 end if
end sub

private sub LoadDb(path as string)
 'if the path does not exist, then exit
 if system.io.file.exists(path) = false then exit sub

 'if we get here then the path is valid
 'connect to database
 'grab data
 'close connection
end sub

Posted

First thanks SomeoneElse for response :hello:

then Im connecting to the data base using OleDataConnection and OleDataAdapter and its running good in both debugging and run-time in my PC only because the connection path of my db.mdb is there.

how to include the db.mdb with the exe file to run on a different PC ??

Posted

If you want to include the mdb with your program you should use an installer.

I use Inno Setup for the projects I deploy.

It's quick, easy, and free :)

As for program setup:

Is the path to the database hardcoded or can it be changed by the user?

I'm just asking since not everyone has an F drive on their computer.

If all you have is an exe and an mdb then I would keep them both together in one directory. Then use Application.StartupPath & "\db.mdb" as the first file check and if it doesn't exist then prompt the user to select where the database is at.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...