Updating access database
-
Hi... I have 2 Questions 1.) I have a button which selects mp3 files and then stores their information into a datagrid and then records changes to the database. The problem is that if I look for files outside of the solution folder and select them to be added to the datagridview an error message appears saying that the database could not be found at the specified location(the location they give in the error isn't where the database is supposed to be located in the first place). It works when adding files within the solution folder and any underlying folders within the solution folder but just not outside of this folder. Any ideas why this could be? My 2nd question is that I have various textboxes on a form that when the user selects a row in the datagridview and enters information into these textboxes then the datagridview should be updated. My textboxes are binded directly to the dataset tables columns and my datagridview to the dataset table. It was throwing a concurrency violation error earlier because i called datgridview.update() in the row leave event for the datagridview as well as a call to a sub called saveChanges which is a standard save procedure which checks if there are changes and updates database if there are. Now that I have removed the saveChanges() call from the rowLeave event for the datagridview..... the final row isn't saving changes. My datasets and table adapters are all generated so as far as I know this shoud all be fine? Can Anyone help? Its an access database by the way...my code works fine that I made to add files to the dataset and create a new row etc. Its just the editing that isn't working? Mr Oizo
-
Hi... I have 2 Questions 1.) I have a button which selects mp3 files and then stores their information into a datagrid and then records changes to the database. The problem is that if I look for files outside of the solution folder and select them to be added to the datagridview an error message appears saying that the database could not be found at the specified location(the location they give in the error isn't where the database is supposed to be located in the first place). It works when adding files within the solution folder and any underlying folders within the solution folder but just not outside of this folder. Any ideas why this could be? My 2nd question is that I have various textboxes on a form that when the user selects a row in the datagridview and enters information into these textboxes then the datagridview should be updated. My textboxes are binded directly to the dataset tables columns and my datagridview to the dataset table. It was throwing a concurrency violation error earlier because i called datgridview.update() in the row leave event for the datagridview as well as a call to a sub called saveChanges which is a standard save procedure which checks if there are changes and updates database if there are. Now that I have removed the saveChanges() call from the rowLeave event for the datagridview..... the final row isn't saving changes. My datasets and table adapters are all generated so as far as I know this shoud all be fine? Can Anyone help? Its an access database by the way...my code works fine that I made to add files to the dataset and create a new row etc. Its just the editing that isn't working? Mr Oizo
1. Sounds like you are defining the path to the database realtive to the working directory, which changes when you choose a file. Get the application path and use that to specify the path of the database. 2. Dunno.
--- single minded; short sighted; long gone;
-
1. Sounds like you are defining the path to the database realtive to the working directory, which changes when you choose a file. Get the application path and use that to specify the path of the database. 2. Dunno.
--- single minded; short sighted; long gone;
Hi... I'm not too sure if I understand but I think you mean that my datbase location is not hard coded. I have it set as "dataSource=..\..\data\Accessdatabase.mdb" for the connection string datasource. the reason why i have done it like this is that i need to move my application around to various workstations while i am developing and I was taught that hard coding my connection string(aka using just the generated connection string) is bad practice? So if I am using a relative path and i choose to publish my software will it give me problems and will I only be able to select files from within the project solution folder to add to my datagridview? Mr Oizo
-
Hi... I'm not too sure if I understand but I think you mean that my datbase location is not hard coded. I have it set as "dataSource=..\..\data\Accessdatabase.mdb" for the connection string datasource. the reason why i have done it like this is that i need to move my application around to various workstations while i am developing and I was taught that hard coding my connection string(aka using just the generated connection string) is bad practice? So if I am using a relative path and i choose to publish my software will it give me problems and will I only be able to select files from within the project solution folder to add to my datagridview? Mr Oizo
Mr Oizo wrote:
Hi... I'm not too sure if I understand but I think you mean that my datbase location is not hard coded.
No, it's because it's relative, so you rely on the working directory. The working directory is changed when you select a file. As I said, get the application directory, and use that as a starting point to reach the database file.
--- single minded; short sighted; long gone;