"Unhandled Exception". Moving database file?
-
Thursday, February 09, 2012 2:30 AM
Hello Everybody,
So I'm creating this VB 2008 application and I want to make it into a CD so it can be installed in other computers. Problem is, after I create the setup and start it even from the computer that created the application in the first place, it gives me the "unhandled exception has occurred in your application. If you click Continue, the application will wignore this error and attempt to continue. If you click Quit, the application will close immediately." and "The following file could not be found: "C:\Users\MyName\AppData\Local\Apps\2.0\Data\\VHMGGXM7.8K8\..." errors. Since my first "form" is a login system, I am not sure if this problem appears because of the database search, or just the transition between forms (unlikely, I guess, since there is sort of an introductory video before the login system which uses the same logic to transition between forms)... So I tried moving the access database to a different path and I wanted to know how to tell the program (through v.b.) that the database is now in "this path" without having to re-connect and create a new Data Set, which will make me have to start the whole project again. I set up the whole project in Program Files (a place all computers must have). The video before the login system works fine, but I can't really find any other problem.
Any suggestions of how I could fix this?
All Replies
-
Thursday, February 09, 2012 7:57 AMI need to understand your issue a bit better, but that unhandled exception is undoubtely an occurance based on the program not being able to find data through that filepath on your computer. Post the code you have and I can help you. I don't know what you're application is about or what it does or what code you have though currently so my assistance to you may seem limited at this point until you can provide more information here.
If a post helps you in any way or solves your particular issue, please remember to use the Propose As Answer option or Vote As Helpful
~ "The universe is an intelligence test." - Timothy Leary ~ -
Sunday, February 19, 2012 7:47 PMThanks, that was the problem, the program couldn't find the access database so I tried moving it to the path specified and it worked flawlessly. Now I just need to find a way to install that database directly to that path while creating the exe.
-
Monday, February 20, 2012 3:19 PM
Hello,
Have you considered placing the database file under the application folder i.e. ApplicationFolder\Data followed by using the following code to create a connection to the database.
Private Sub demo() Dim FileName As String = IO.Path.Combine(Application.StartupPath, "Data\Your_Database_Name.accdb") Dim cb As New OleDb.OleDbConnectionStringBuilder With {.DataSource = FileName, .Provider = "Microsoft.ACE.OLEDB.12.0"} Dim cn As New OleDb.OleDbConnection With {.ConnectionString = cb.ConnectionString} End SubKSG
- Marked As Answer by Shanks ZenMicrosoft Contingent Staff, Moderator Tuesday, February 28, 2012 8:56 AM

