I have create an application for windows, where i am using phone's sqlite as DB to store data. While testing the app in Emulator after the first time(i.e reinstallion of the app), the data of the DB gets erased every time.
So can any one please tell me How to:
Save the existing data of the DB before reinstalling the app.
Modify the .sdf file Manually (with out using the app)
To save the data in some other way, which will not be affected by the reinstallation of the app.
More Information regarding ways to add data to .sdf file are appreciated ...
Edit: Is it possible to browse and edit the .sdf file in phone when application gets installed
If you run the app via the Emulator, every time you close the emulator the app along with its components gets uninstalled. To prevent this , don't close the emulator everytime you run the app. Keep the emulator open, and run the program.
In the phone once the app is installed, the data is not deleted from the database and it is persisted.
The SDF can be modified using the Server Explorer in Visual Studio, add a database connection to SQL CE 3.5 and point to your sdf. You can modify the data from there.
You can also use the Isolated Storage explorer to open the SDF. http://wp7explorer.codeplex.com/
Related
I've already an offline updater as a download but I want to make it automatically. It's a client/server software and a ms sql database.
3 parts have to be updated:
update of a proprietary software (setup.exe with next, next, type login/password for server service, finish) which delivers a WinClient and a Service for the server. Autoupdate is only needed for server, the autoupdate for clients by the server works already.
one .hug file which contains new customized program version. The path is a directory in the above software and can be determined with registry.
MS SQL database update with new content (in a .bak file) and structural changes. The database server is sometimes another server as application server. At the moment you have to type in the SQL instance when running the udpater.
My ideas are these:
a updater program in the tray on application server and database server
updater searches with a timer for newer versions on my ftp server and downloads the files if existing
on application server it runs the setup.exe and copies the .hug file. Maybe I could make it silent with command prompt commands. But still need to fill in login/password for the service user.
on database server I configure the autoupdater once with instance name. Updater downloads .bak-file and runs sql script with insert, update and alter statements.
but one big problem which can cause problems is when users are still logged in. Don't know in the moment how I could solve that.
So, how would you realise such a project? Or have you already done something similiar? Is its generally possible?
im using MS-access as my database. I've already finished the project and it is working perfectly fine.
my database location while im still developing is in C:\Users\Users\documents and the other one located at C:\Users\Users\documents\visual studio 2010\projects\project1\project1\bin\debug
is bad to put the database at two different folder?
1st problem: now creating a setup and deployment project, i use setup wizard and checked all then build it. installation of setup is successful but when i try to run the program, it doesnt respond,
2nd problem: i cant see my 1st database located at program files, only the second one and maybe this is the cause of unresponsive app.
copying the debug files into other computer and copying manually my database to user\document which i have to change permission and the copied debug files runs well, but i have to create an installer. how to do it?
from my server explorer i was wondering there is only one database, yet my program works fine when running debug? reconnecting the unseen database would be a lot of work because it is my main database.
You should check the database which is connected to your project and the path which is associated.
Try Application.StartUpPath in your connection.
I recently developed a winform application with c# and SQL Server 2008 data access. I want to create an "InstallShield express" setup file for it (I don't want to use ClickOnce or Setup And Deployment witch is available in VS). I want to create a db or attach it to SQL server instance after installing SQL Server Express 2008 SP3 (not local db). What is the best way to do this?
Your question is quite vague as you do not explain what kind of “app”, “setup file” or “db” you are using, nor how you “attach it to sql”. In the future, please include these details. However, I can give a general answer.
Create a seed database, that contains the starting data for your application, in your source project.
Add the seed database file to your project/solution file and set its Build Action to “Content”.
Ensure your installer includes project content in the deployment folder (the application folder for WinForms apps).
To open the seed database from your app, use a connection string like Data Source=|DataDirectory|seed.sdf. Do not try to search for your seed file or to set DataDirectory yourself; the installer will set DataDirectory to the directory your content was installed to.
Do not try to write to DataDirectory; it may not be writable by the user who installed it. Repairing the app will overwrite DataDirectory, destroying anything you saved there, as well.
If you need to save data in the database, copy |DataDirectory|seed.sdf to Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), then read and write all data to the copy.
For more information, read my answer to a poster who wrote to |DataDirectory| and therefore kept destroying his user's data.
I recently switched a windows forms application to use SQL Compact 4 database and Entity Framework. I handle the updates to the application through the application (no windows services). When an update is sent out to the device, all data is cleared (the data directory is deleted) and the exe gets replaced with a new exe.
This works fine except the next time the application is launched, Windows pops up with a message "Please Wait While Windows Configures 'Application Name'". Windows then proceeds to add back the database file automatically and set my exe back to the previous version.
Why is Windows adding the old database file and reverting my exe? How do I stop this from happening?
It appears that adding the database to the program data folder in the installer project caused this. Removing the file from there and programmatically adding the database file there resolved this issue.
I have a simple WPF application that uses ClickOnce to handle installing. Within this application is a compact database. Through testing I have found that when I publish a new build this database will get overwritten, which is not what I want. Is there anyway I can have fine grained control over what files are updated? I assume ClickOnce is simply checking the hash of the database file, deciding that it has changed and pulling the update.
As a workaround I have since removed the database from the files that are included with the published application so the original remains on the client machine after an update, untouched.
Not a great solution I know
Thanks,
ClickOnce deployments segregate the Application Files into "Include" or "Data file". You can specify what each file is in visual Studio by going to the project Properties page, Publish tab, then clicking the "Application Files..." button. You can then set your .sdf file to "Data File" under the Publish Status column.
Data Files that are downloaded with a ClickOnce application are then placed in a separate directory for each new version.
The idea is that on the first run of the new application version, you go retrieve all the user's private data from their old-version data files and incorporate that data into the new data files which have just been downloaded with your new version.
I think you'll find the information you need at Accessing Local and Remote Data in ClickOnce Applications. Specifically, look at the sections "ClickOnce Data Directory" and "Data Directory and Application Versions."
To access a SQL Server CE database located in your Data directory, use a connection string similar to the following:
<add
name="MyApplication.Properties.Settings.LocalCacheConnectionString"
connectionString="Data Source=|DataDirectory|\LocalCache.sdf"
providerName="Microsoft.SqlServerCe.Client.3.5" />
The "|DataDirectory|" is a special syntax supported by SQL CE and SQL Express and resolves at runtime to the proper directory.
If you so much as open that SQLCE database included in your project, it will change the time stamp on the database, and ClickOnce will deploy it and put the old version under the \pre subfolder.
You might want to consider this method for handling this. Then if you accidentally deploy a new version of the database and don't realize it, you're not hosed. If you intentionally make changes, you can change the database structure of your current database with SQL queries, and pull data from the new copy deployed to the Data Directory (that you're otherwise ignoring) when you need to.
RobinDotNet