I have written a Windows application in Visual Studio that reads data from a Microsoft Access database. Everything works fine; however, after publishing the application I need it to read the database when the database is changed or updated. Can anyone help with where to put the Access database and how to get the application to look at it when it opens?
It sounds to me like you can place the Microsoft Access (presumably, a single .accdb file) anywhere you want to put it and then--as long as your program knows where that file is--simply use System.IO.FileSystemWatcher.
See this question/answer(s) for more details:
Notification when a file changes?
Related
I have inherited a database that was created in Visual FoxPro. I don't have that program. Currently I have Access 2007. I've been trying to get External Data using an VFPOLEDB file that I got from the Microsoft website. When I try to use it with Microsoft Query its not listed. I used the Setup Installer Package. Do I need to put it somewhere special? Its in the common files\system\ole DB folder. Along with all of the other .dll files.
I'm at my wits end. Keep in mind I don't have the VFP program. If this is why I'm failing please yell at me. Then I'll know all is lost and I can just quit my job and become a hobo.
Try using the ODBC driver instead see:
http://msdn.microsoft.com/en-us/library/ms714034%28v=vs.85%29.aspx
How do I move a .sdf file into my isolated storage and after I have moved it is there a way to delete it as it is of no use. I have added my .sdf file as a content in my project.
Your question is not very clear, but let me see if I get this. You created a database, added it to your file as content to your project so that you can have all the data present when the user installs your app. Then you are copying the data from the read-only .sdf file into a database that you are creating on first run, so that you can read/write to it. Correct?
If so, I do not believe there is a way to delete the read-only file that you included with the install.
If your database is large enough that you are concerned about the space it will take by having two copies of it on the phone, I would suggest placing your data on a server, creating a web service, and access that web service on first run. Place a notice on the screen that lets your user know that it is downloading information that will only be downloaded once, and that subsequent launches will not take as long. Be sure you include code to prevent a problem should the download be interrupted by a phone call, text message, back key press, start button, or other event. Make it be able to continue the download if it was interrupted in a prior run.
To answer your question, .SDF is a format of Microsoft SQL Server Compact (SQL CE) databases. The link you have pasted talks about SQLite databases.
This the way to download the entire Isolated Storage onto your device.
Open cmd and go to the following directory
C:\Program Files\Microsoft SDKs\Windows Phone\v7.1\Tools\IsolatedStorageExplorerTool
then use the isetool.exe to download the Isolated Storage along with the .sdf file onto your machine.
isetool.exe ts xd [Product_id_here_see_WMAppManifest.xml] "D:\Sandbox"
You should get message like download successful into D:\Sandbox.
You can also upload the sdf by changing the argument ts with rs
I have been asked to create an MVC web application in VS 2010, and was instructed to use a SQL express database for my data. I am using EF Code-First for creating and managing my data. The database was created in VS2010, and is attached via "AttachDBFilename" in the web.config.
I have used SQL CE before with MVC with no problems, however the attached SQL Express DB is causing weird issues.
For one thing, when I try to deploy the app, it fails and tells me that it cannot copy the database.mdf because it is in use by another process. I have NOT opened the database in VS2010 nor SSMS. Of course the program code accesses it - is there some reason that connection would remain open? I am using boilerplate code from the scaffolding.
I should mention that I use a ProjectInitializer.cs to create the sample data. It runs at every launch for the moment, since I am testing quite a bit.
The other problem I have is that if I delete the database, it fails to recreate it. It says that my windows account does not have access to the (now non-existent) database that it is trying to create. I literally have to create a new database with new name, as anything that was created previously (with that DB name) fails.
I assume there is some sort of residual info being left somewhere that is out of synch, but I don't know what it is. I've closed all connections to the file in VS 2010, deleted the files, both any found via VS2010 and any physical files I see in the app_data directory.
Any help or suggestions would be appreciated.
Shut down the web server (Cassini, IIS, IIS Express) and try again. The file can remain locked if the web process is still referencing the file. In addition the loaded EF context will retain the db name. Ensure the visual studio browser isn't running in the tray still either.
I am deploying an .accdb file to the same directory as my windows forms program is being installed. However when attempting to update data in the database i get a "Operation must use an updateable query" error.
The file attributes are not read only, however when I open the accdb file it stats that the database has been opened read only. I must save a copy to make it not read only.
I do not believe this has anything to do with permissions, or file attributes. This is only on Vista, XP appears to work ok. The original accdb file is not read only when i open it.
What is visual studio doing to the accdb file to make it read only? and how can i fix it.
Are you installing into the Program Files heierarchy? If so that's read only for users and would cause the Access database to be read only. You should be installed any Access database file to the users Application Data folder.
I'm developing a simple database app in visual studio (c# for Windows) using an access backend.
That's all fine until I try to open the database file from within access, when all the reocords get deleted.
Could anyone explain why this is please?
Did you add the database to your solution? Select it and check the Copy Local (aka Copy to Output Directory) setting in the Properties window. Make sure it isn't set to Copy Always,
We need more information. You say that when you open the database from within access, "all the records get deleted". The way the question is phrased implies that some process is running as part of opening the database, e.g., an autoexecute macro. Do you really know that is what is happening? Or are you really just saying that "when I open the database file from access, the records are not there". If the latter, then something is happening along the lines of what cletus suggests.
This is an old question and I don't know if the original poster is still around, but something that didn't occur to me at the time I originally read the question was that perhaps the C# app is using a transaction to insert the data and is not committing it. If that were the case, the data would be visible in the C# app and would not be there when you opened the file in Access. On the other hand, the data wouldn't be there in a new session of the C# app, either, so this might not be the issue.