Can't get data out of .mdf file - c#

I created a project a while ago and transferred it to my other computer, and now it's stopped working. I can't manage to fill the grid with the data from the .mdf.
I have struggled a while with this problem and I can't manage to solve it. I would appreciate if someone here could download the .rar and help me solve this problem.
http://www.filefactory.com/file/3wabxfsyxign/n/CDapplikation_uppgift_rar

.mdf are SQL Server data files; for working with those files, you must have some version (other than Compact Edition) of SQL Server installed
So to get this data out:
check to see what version of SQL Server you have installed
fire up the management tool, e.g. SQL Server Management Studio (possibly the Express version which you can find by searching on Google or Bing and download for free from Microsoft)
attach the .mdf file to the SQL Server under a logical name, so that you can use it
now you can access it using raw ADO.NET or Entity Framework or whatever other data access technology you wish to use

Related

Create Backup of Attached SQL Server Project in Visual Studio

Good day!
I'm trying to create a standalone C# project with a SQL Server database attached so I only need to install a SQL Server Compact Edition.
I managed to connect to the said database and do some basic display, add and delete.
What I'm trying to do now is to have an option for the users to backup and restore the database.
Upon checking the files of the project, the tables and stored procs are in script format. Is it possible for it to be backed-up the same as how .mdf database files are backed-up and restored?
I am also open to suggestions on ways on how to easily have a standalone project be developed. So far this is only what I got. Thanks in advance guys!

Cannot add new Local Database in Visual Studio 2013

I am going through a tutorial that is adding a simple local database to a C# console application but when adding a new item to the solution I cannot find the Local Database to insert a .sdf database file. I have tried to download SQL Server Compact 4.0 but upon installation it says that SQL Server Compact 4.0 is already installed on the computer. Below is a screenshot of the available data resources I can add.
How would I be able to add a local database file to my solution?
You should use the ADO.NET Entity Data Model and use Entity Framework to generate models from your database. You can select your local database there.
Eventually found this question that has already been answered that solved my problem
How to connect to LocalDB in Visual Studio Server Explorer?

Visual Studio How to Publish Application that uses data from an Online Database

Hi I published my desktop application on visual studio as a clickOnce installation but I seem to have problems with SQL and Entity Framework Exceptions as this is what my software uses in order to display data. Is there any other way to get around this problem ? Here is an image of what happens when the user wants to see the specific data. Mostly the Exceptions range from both SQL and Entity Frameworks. This only happens upon another computer and not mine which the Software was created on.
Any help would be greatly appreciated !
If you wish to deploy your database with the application binaries then you can try SQL Server Compact instead of the full version of the server, which requires the server to be installed on the machine. The msdn link here will help you with the process -
http://msdn.microsoft.com/en-us/library/aa983326(v=vs.110).aspx
and you can download the application from here -
http://www.microsoft.com/en-us/download/details.aspx?id=17876
In short, SQL Server Compact databases files (.sdf) can be deployed along with your application and some binaries and dlls to help it work on the destination. The msdn topic will show you how to do this.
The full documentation and a good starting point is here too -
http://msdn.microsoft.com/en-us/library/aa983321(v=vs.110).aspx
IMPORTANT Entity framework has some limitations when working SQL Compact Databases, make sure you check and see that this won't be a problem for you.
http://technet.microsoft.com/en-us/library/cc835494(v=sql.110).aspx

Can't use SQL Server CE in VS2012

I'm developing a web application and was trying to use a local database file to store some information. However, when I add the .sdf file, I get an error. Below are some screenshots detailing my problem.
I've been trying to figure what's wrong for several hours. I've seen similar issues, but have yet to find a fix. I used to be able to use SqlServerCe connections before with .sdf files, though that was a different development environment. I have tried reinstalling everything SQL several times, including downloading everything I could find on MSDN. Can anyone help me out?
Below is my Solution Explorer View. I've just added Database1.sdf to the project.
I get an error as soon as I add it:
If I try to open the .sdf file, I get this error:
Here is my list of references:
And, finally, all of the relevant SQL-related installations on my local machine:
SQL Server Compact 4.0 is supported by VS 2012, but requires the DDEX provider to be properly isntalled. Sounds like your VS install is somehow broken. You can install my Toolbox add-in, and go to the About dialog in the Toolbox to check if the DDEX provider and SQL Server CE 4.0 is properly installed.

how to change database version from 655 to 612?

Error -
mdf file can not be opened because it is version 655, this version
support 612 or earlier
Note :
I am created this database file using SQL Server 2005 and later that file is opened in SQL Server 2008 then automatically change version from 612 to 655.
But I currently want to open that file in SQL Server 2005.
Any solution is possible then help me.
Upgrading an mdf is a one-way process. You'll have to go back to a backup, an earlier version of the file or recreate it.
I'm guessing you don't have backups or an earlier version of the file (nobody posting "how do I get something back" on these sites knows what a backup is).
As far as recreating goes, you can attach the database to a SQL Server 2008 instance (or later) and then use SQL Server Management Studio to export the database into a blank database on an '05 instance.
From within Management Studio use the Generate Scripts Wizard. You can use this wizard to build queries that will reconstruct the database. Make sure you choose to script Schema and Data and set the destination server version as SQL Server 2005.
Alternatively, you can use the SQL Server Import and Export Wizard although it may not bring all your database objects across.

Categories