B
Brian
It's still not working - is still looking for the Database in the same
folder as the photo just added.
But i've realised something... bear with me here!
The basics of the way my photo album works is as follows:
- A database containing photo_id (as a primary key), location
(location of photo on disk), caption etc are contained in a table in a
Database (photoDB.mdb) in the Debug folder of the project
- User opens the Photo Album program
- The Browse Photos form opens... in which photo id's are loaded from
a database into a ListBox
- When you select a photo id from the ListBox, it will get the file
location for that appropriate photo_id from the database and load it
into a picture box opposite the ListBox
- I use the same connection settings (to the database) for everything
- when the form loads, when the user selects a new photo id, when a
user deletes a photo... all works fine!
- But then clicking to open the Add Photo form then, i get the
problem!
I tried using the connection setting i've been using all along and it
looks for the Database in the same location (folder) as the photo i'm
adding. Tried using different form of connection settings /
suggestions i've been getting and they all end up the same: looking
for the database in the folder as the photo i'm adding.
However, if i skip the form involving Browsing The Photos, selecting
photos etc. and just go straight to the form to Add a new Photo.. that
connection setting works successfully and all is fine.
It's on when i load the Browsing Photo form.. and then try and open
the Add New Photo form that i get a problem.
Very long, detailed and confusing problem, i know!
By the way, i am closing the connection to the Database each time i
use it.
Any suggestions why the problem doesn't occur if i go straight to the
Add Photo form (bypassing the Browsing Photos form)? Would it be
because i'm re-using the same connection settings, variable names
(etc.) even though i'm closing the database after each method.
The connection string (that i'm re-using) is below:
string strDSN = "Provider=Microsoft.Jet.OLEDB.4.0;Data
Source=photoDB.MDB";
string strSQL = "SELECT * FROM photos" ;
OleDbConnection myConn = new OleDbConnection(strDSN);
OleDbDataAdapter myCmd = new OleDbDataAdapter( strSQL, myConn );
myConn.Open();
DataSet dtSet = new DataSet();
myCmd.Fill( dtSet, "categories" );
DataTable dtAddTable = dtSet.Tables[0];
Then after that, i take the appropriate action (loading to a ListBox /
ComboBox) and close the connection to the database.
Any suggestions as to where i might be going wrong would be much
appreciated!
Thanks for all the help, Brian.
folder as the photo just added.
But i've realised something... bear with me here!

The basics of the way my photo album works is as follows:
- A database containing photo_id (as a primary key), location
(location of photo on disk), caption etc are contained in a table in a
Database (photoDB.mdb) in the Debug folder of the project
- User opens the Photo Album program
- The Browse Photos form opens... in which photo id's are loaded from
a database into a ListBox
- When you select a photo id from the ListBox, it will get the file
location for that appropriate photo_id from the database and load it
into a picture box opposite the ListBox
- I use the same connection settings (to the database) for everything
- when the form loads, when the user selects a new photo id, when a
user deletes a photo... all works fine!
- But then clicking to open the Add Photo form then, i get the
problem!
I tried using the connection setting i've been using all along and it
looks for the Database in the same location (folder) as the photo i'm
adding. Tried using different form of connection settings /
suggestions i've been getting and they all end up the same: looking
for the database in the folder as the photo i'm adding.
However, if i skip the form involving Browsing The Photos, selecting
photos etc. and just go straight to the form to Add a new Photo.. that
connection setting works successfully and all is fine.
It's on when i load the Browsing Photo form.. and then try and open
the Add New Photo form that i get a problem.
Very long, detailed and confusing problem, i know!
By the way, i am closing the connection to the Database each time i
use it.
Any suggestions why the problem doesn't occur if i go straight to the
Add Photo form (bypassing the Browsing Photos form)? Would it be
because i'm re-using the same connection settings, variable names
(etc.) even though i'm closing the database after each method.
The connection string (that i'm re-using) is below:
string strDSN = "Provider=Microsoft.Jet.OLEDB.4.0;Data
Source=photoDB.MDB";
string strSQL = "SELECT * FROM photos" ;
OleDbConnection myConn = new OleDbConnection(strDSN);
OleDbDataAdapter myCmd = new OleDbDataAdapter( strSQL, myConn );
myConn.Open();
DataSet dtSet = new DataSet();
myCmd.Fill( dtSet, "categories" );
DataTable dtAddTable = dtSet.Tables[0];
Then after that, i take the appropriate action (loading to a ListBox /
ComboBox) and close the connection to the database.
Any suggestions as to where i might be going wrong would be much
appreciated!
Thanks for all the help, Brian.