Hi guys,I'm building an application which will hold details of my CD collection. One of the features is for a JPEG of the album cover to show whenever I select an album. In cases where I don't have a .jpg of the cover, a link label is enabled to allow me to get one from the 'net. When I've saved this onto the hard drive, I use an OpenFile dialog to browse to the picture location and display it in a picture box. At this point I want to update the database with the full path to the .jpg file using the following code:
ImageFile is taken from dlgOpen.FileName and in my test case is set to C:\Documents and Settings\Brian\My Documents\Visual Studio 2005\Projects\Class 10\Exercise 10\Exercise 10\bin\Debug\Covers\Master Of Puppets.jpg
This is where I've hit my problem. For this application, I've put the .mdb file into the DataDirectory, so the full path to the file is C:\Documents and Settings\Brian\My Documents\Visual Studio 2005\Projects\Class 10\Exercise 10\Exercise 10\music.mdb. However, when the application tries to update the database, the full error message I'm given is
Message="Could not find file 'C:\Documents and Settings\Brian\My Documents\Visual Studio 2005\Projects\Class 10\Exercise 10\Exercise 10\bin\Debug\Covers\music.mdb'."
This indicates to me that the application is now looking for the .mdb file in the last directory opened with the OpenFile dialog. If I move a copy of the .mdb file into this directory, the application successfully updates the required field, so I know the code itself is working properly. What I don't know is:
1. Why is the path to the Access file being changed?
2. How can I stop the path being changed?
If anyone requires any additional information on this, just ask and I'll be happy to supply it.
Any help you can give will be much appreciated.
VB.NET:
Dim SQL As String
Dim UpdateCommand As OleDb.OleDbCommand
SQL = "UPDATE music.albums SET CoverImageLocation = '" + ImageFile + "' WHERE AlbumName = '" + AlbumName + "'"
UpdateCommand = New OleDb.OleDbCommand(SQL, OleDbConnection1)
OleDbDataAdapter1.UpdateCommand = UpdateCommand
OleDbDataAdapter1.Update(Music11, "albums")
This is where I've hit my problem. For this application, I've put the .mdb file into the DataDirectory, so the full path to the file is C:\Documents and Settings\Brian\My Documents\Visual Studio 2005\Projects\Class 10\Exercise 10\Exercise 10\music.mdb. However, when the application tries to update the database, the full error message I'm given is
Message="Could not find file 'C:\Documents and Settings\Brian\My Documents\Visual Studio 2005\Projects\Class 10\Exercise 10\Exercise 10\bin\Debug\Covers\music.mdb'."
This indicates to me that the application is now looking for the .mdb file in the last directory opened with the OpenFile dialog. If I move a copy of the .mdb file into this directory, the application successfully updates the required field, so I know the code itself is working properly. What I don't know is:
1. Why is the path to the Access file being changed?
2. How can I stop the path being changed?
If anyone requires any additional information on this, just ask and I'll be happy to supply it.
Any help you can give will be much appreciated.