coboy Posted July 17, 2005 Posted July 17, 2005 Hi 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 ??
SomeoneElse Posted July 17, 2005 Posted July 17, 2005 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 loaddim 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 ifend subprivate 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 connectionend sub
coboy Posted July 17, 2005 Author Posted July 17, 2005 First thanks SomeoneElse for response 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 ??
SomeoneElse Posted July 17, 2005 Posted July 17, 2005 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.
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now