If this question has been asked before please point me in the right direction.
I am working with an MDF file which I attach to localdb in Visual Studio.
However, when I run my application it is copied to the Debug folder (I know this is because the "Copy always" option is set)
This works fine because my connection string is:
Data Source=(localdb)\v11.0;AttachDbFilename=|DataDirectory|\Invoicing.mdf;Integrated Security=True
which means my application will look for the database in the Debug folder.
My question is, where should I place the database file because :
1. The file I am attaching to localdb is under the projects folder
2. Meanwhile, my application looks for the database file in the debug folder
I would appreciate any guidelines
I found this article:
http://msdn.microsoft.com/en-us/library/ms246989.aspx
I guess I will have to attach the one in the bin folder and choose the option to copy if newer
EDIT:
I have done the above and in addition I have created two connections, one for the MDF in the projects folder and the other to view data in the database in the bin folder
Related
Each time the program is run, or when the program is edited and run, the SQL Server database (.mdf file) is cleared and only the data given later is seen. All old data is cleared.
I made this program in Visual Studio 2010. How to fix this? How can the data be permanently saved to the SQL Server database?
Have you verified that you are looking at the correct MDF file? When you run your program it will copy to a folder under [ProjectFolder]/bin - if you are running the Debug configuration it will be [ProjectFolder]/bin/Debug/yourFile.mdf and if you are running the Release configurations it will be [ProjectFolder]/bin/Release/yourFile.mdf. These are separate from the MDF file that is likely in the project root ([ProjectFolder]). If you are making changes when the program is running, it will be saved (assuming your code is correct) to one of the MDF files that exist under the [ProjectFolder]/bin folder.
I am trying ti add some new features to my already installed Sql Server instance.
I run the installation setup and chose the option to add new features to existing instance of Sql Server 2016 RC3. Checked the options I wanted to add and then continued to next step. At the step where I add Authentication Mode and the server administrators I am having an error like below in the image.
The problems is obvious but is it obligatory to 'delete' master.mdf file and tempdb.mdf file before starting the installation or do something else ?
I dont want to change the locations of the master db files because I dont want to create two directories for the same purpose with two databases with the same purpose again.
Open Explorer and navigate to the folder in question (in my case):
C:\Program Files\Microsoft SQL Server\MSSQL13.MSSQLSERVER\MSSQL\DATA
Control-A (select all), Control-X (cut)
Create a new folder: DATA_OLD
Go into the DATA_OLD folder, Control-V (paste)
You can now install SQL Server. Note: You will have to re-link any previously existing databases from the DATA_OLD folder.
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'm trying to open an old MS Access 2000 Database that was working on windows XP, so that i can migrate the old DB in a new application. The DB was created by the previous old WPF application and I need to find a way to open it. I installed MS Access 2000 and used a program that generated the right password for the db but there is still this message that pops up:
You do not have the necessary permissions to use C:/pathToDB.MDB object. Have your system administrator or the person who created this object establish the appropriate permissions for you.
Is there a way to solve this problem?
Many thanks.
Earlier versions before 2007 had something called as the MDW (Microsoft Access Workgroup) file with the MDB .
If you cannot find this, you can create one. To create this file, first create a new shortcut Right click New > Shortcut>. When asked type the location of the item. You will need to enter the following, replacing MDB/MDW> to where your files are located and the version of Office you are using. It may be worth opening notepad so you can get the path right and then copy and paste.
"C:\Program Files\Microsoft Office\Office14\MSACCESS.EXE" ".mdb" /wrkgrp ".mdw" /user
Replace Office14 with your version of Microsoft office that is installed. To find this, browse to “C:\Program Files\Microsoft Office\ and note the “Office” folder.
Use this new shortcut to open your file. It should hopefully sort it out.
delete the .ldb file and this should solve your problem. The .ldb file is created when a new session is created. If the program crashes, the .ldb file will not be deleted.
Hope this helps you.
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