convert .mdf to .sdf

  • (2 Pages)
  • +
  • 1
  • 2

18 Replies - 18585 Views - Last Post: 21 May 2010 - 12:47 AM Rate Topic: -----

#1 xikky  Icon User is offline

  • D.I.C Head

Reputation: 1
  • View blog
  • Posts: 88
  • Joined: 19-December 09

convert .mdf to .sdf

Posted 14 May 2010 - 07:17 AM

Please anybody has any idea how i can convert my .mdf file to .sdf so i can attach my database to my c# project using sql compact?

i tried to search google and tried some software like CONVERT KilletSoft Primeworks but it's all in vain :( or i don't know how to manage the programs! :S

any help pls?

thank u!

Is This A Good Question/Topic? 0
  • +

Replies To: convert .mdf to .sdf

#2 W3bDev  Icon User is offline

  • D.I.C Regular
  • member icon

Reputation: 42
  • View blog
  • Posts: 379
  • Joined: 15-March 09

Re: convert .mdf to .sdf

Posted 14 May 2010 - 07:39 AM

http://www.codeproje...optUtility.aspx
Was This Post Helpful? 2
  • +
  • -

#3 xikky  Icon User is offline

  • D.I.C Head

Reputation: 1
  • View blog
  • Posts: 88
  • Joined: 19-December 09

Re: convert .mdf to .sdf

Posted 14 May 2010 - 08:16 AM

thanks a lot m8 :) it worked 100% xD

i've got another problem tho..

with the .mdf file i used to connect with this string..
con = new SqlConnection("Data Source=.\\SQLEXPRESS; AttachDbFilename=|DataDirectory|\\supermarketdb.mdf;Integrated Security=True;User Instance=True");



now when i change the supermarketdb.mdf to .sdf i doesn't work but gives me this error ..

an attempt to attach an auto-named database for file ... failed. A database with the same name exists, or specified file cannot be opened, or it is located on UNC share

and is it possible to create stored procedure with this type of connection .. just asking coz i didn't see the stored procedures in the Server Explorers

any help will be greatly appreciated :)
Was This Post Helpful? 0
  • +
  • -

#4 eclipsed4utoo  Icon User is offline

  • Not Your Ordinary Programmer
  • member icon

Reputation: 1524
  • View blog
  • Posts: 5,960
  • Joined: 21-March 08

Re: convert .mdf to .sdf

Posted 14 May 2010 - 08:25 AM

1. You will need to change your connection string. You are not running a SQL Express database anymore. SQLCE(which is what .sdf is) uses a different connection string.
http://www.connectio...-server-2005-ce

2. SQLCE doesn't support stored procedures.

This post has been edited by eclipsed4utoo: 14 May 2010 - 08:27 AM

Was This Post Helpful? 1
  • +
  • -

#5 xikky  Icon User is offline

  • D.I.C Head

Reputation: 1
  • View blog
  • Posts: 88
  • Joined: 19-December 09

Re: convert .mdf to .sdf

Posted 14 May 2010 - 08:28 AM

i have to stick to .mdf then :/ ... i need stored procedures for my assignment.

problem is that i managed to connect the database to my c# project but i couldn't add edit or delete while executing the program ..
Was This Post Helpful? 0
  • +
  • -

#6 eclipsed4utoo  Icon User is offline

  • Not Your Ordinary Programmer
  • member icon

Reputation: 1524
  • View blog
  • Posts: 5,960
  • Joined: 21-March 08

Re: convert .mdf to .sdf

Posted 14 May 2010 - 09:11 AM

SQL Express isn't meant to be added to a project. It's a service-based SQL instance. You install SQL Express, then you connect the application to the running instance...not to the file.
Was This Post Helpful? 1
  • +
  • -

#7 xikky  Icon User is offline

  • D.I.C Head

Reputation: 1
  • View blog
  • Posts: 88
  • Joined: 19-December 09

Re: convert .mdf to .sdf

Posted 14 May 2010 - 09:18 AM

sorry for my newbish questions .. but what do u mean by the running instance?

and what datasource shall i use when using SQL Express
-Microsoft SQL Server
or
-Microsoft SQL Server Database File?
Was This Post Helpful? 0
  • +
  • -

#8 eclipsed4utoo  Icon User is offline

  • Not Your Ordinary Programmer
  • member icon

Reputation: 1524
  • View blog
  • Posts: 5,960
  • Joined: 21-March 08

Re: convert .mdf to .sdf

Posted 14 May 2010 - 09:51 AM

You would use "Microsoft SQL Server" when choosing the datasource.

A service-based instance is an instance of SQL Server that is running as a service. You can open your Services(Control Panel --> Administrative Tools --> Services) and you will see SQL Server services running.
Attached Image

On my PC, I have the full versions of SQL2005 and SQL2008, but I also have SQL Express 2005. This is what your instance will look like. When you specify this in your connection string("Data Source=.\\SQLEXPRESS"), this is what you are connecting to.
Was This Post Helpful? 1
  • +
  • -

#9 xikky  Icon User is offline

  • D.I.C Head

Reputation: 1
  • View blog
  • Posts: 88
  • Joined: 19-December 09

Re: convert .mdf to .sdf

Posted 14 May 2010 - 09:59 AM

thanks a lot for your help eclipsed4utoo, hope i'm not bothering u too much ^^

but if i choose Microsoft SQL Server will my program run on other machines (with sql installed ) with same database and with add/edit delete functions working properly?
Was This Post Helpful? 0
  • +
  • -

#10 eclipsed4utoo  Icon User is offline

  • Not Your Ordinary Programmer
  • member icon

Reputation: 1524
  • View blog
  • Posts: 5,960
  • Joined: 21-March 08

Re: convert .mdf to .sdf

Posted 14 May 2010 - 11:10 AM

View Postxikky, on 14 May 2010 - 11:59 AM, said:

thanks a lot for your help eclipsed4utoo, hope i'm not bothering u too much ^^

but if i choose Microsoft SQL Server will my program run on other machines (with sql installed ) with same database and with add/edit delete functions working properly?


No bother. SQL Server can be confusing to beginners.

There are a number of options. You could have the database in a central location where all workstations could get to it, or you could install SQL Express on the client PC.

You can use a command line script to install SQL express.

Is this a school project that is only run on your PC, is this something in a networked environment, or is this a completely disconnected database where the data is specific for each PC?
Was This Post Helpful? 0
  • +
  • -

#11 xikky  Icon User is offline

  • D.I.C Head

Reputation: 1
  • View blog
  • Posts: 88
  • Joined: 19-December 09

Re: convert .mdf to .sdf

Posted 14 May 2010 - 11:22 AM

yep its a school project xD that should be run on any PC with the database updated whenever it is used.

Example if i add an Employee ID and his details on my PC or any PC, when i use the project on another PC (without network) it should find the previously added Employee ID and details.

can u suggest ur best way to connect my project with the database for my purpos pls?
Was This Post Helpful? 0
  • +
  • -

#12 eclipsed4utoo  Icon User is offline

  • Not Your Ordinary Programmer
  • member icon

Reputation: 1524
  • View blog
  • Posts: 5,960
  • Joined: 21-March 08

Re: convert .mdf to .sdf

Posted 14 May 2010 - 11:45 AM

View Postxikky, on 14 May 2010 - 01:22 PM, said:

yep its a school project xD that should be run on any PC with the database updated whenever it is used.

Example if i add an Employee ID and his details on my PC or any PC, when i use the project on another PC (without network) it should find the previously added Employee ID and details.

can u suggest ur best way to connect my project with the database for my purpos pls?


Let me make sure I understand the requirement.

1. You could have X number of PCs.
2. None of the PCs are connected to a network, internet, or each other.
3. You want to be able to add/update/delete records on one PC and have ALL other PCs see that change.

If all three of these are correct, you are screwed because that's not possible. If there is no connection between the PCs, there is no way for them to talk to each other, giving them no way to notify each other of the database changes.
Was This Post Helpful? 0
  • +
  • -

#13 xikky  Icon User is offline

  • D.I.C Head

Reputation: 1
  • View blog
  • Posts: 88
  • Joined: 19-December 09

Re: convert .mdf to .sdf

Posted 14 May 2010 - 11:53 AM

Point 1 and 2 are gd Sir! xD

i didn't make my self clear enough.

- Add/edit/delete on one PC and changes are saved to the database connected
- when used on another PC The program show up with the previous changes

it's like a portable database ... like the sql compact database mentioned before but i am needed to work with stored procedures so sql compact is out of question :/
Was This Post Helpful? 0
  • +
  • -

#14 eclipsed4utoo  Icon User is offline

  • Not Your Ordinary Programmer
  • member icon

Reputation: 1524
  • View blog
  • Posts: 5,960
  • Joined: 21-March 08

Re: convert .mdf to .sdf

Posted 14 May 2010 - 11:59 AM

do you mean the database will be moved? As in something like this...

-- changes made to the data in the database
-- database is copied from PC-A to a flash drive(or other storage media)
-- storage media is plugged into PC-B
-- database is copied from storage media to PC-B
-- application is opened on PC-B and the data changes are there

is that correct?
Was This Post Helpful? 0
  • +
  • -

#15 xikky  Icon User is offline

  • D.I.C Head

Reputation: 1
  • View blog
  • Posts: 88
  • Joined: 19-December 09

Re: convert .mdf to .sdf

Posted 14 May 2010 - 12:02 PM

yep! is this possible? ^^

EDIT: and the database should be part of the project of course

This post has been edited by xikky: 14 May 2010 - 12:03 PM

Was This Post Helpful? 0
  • +
  • -

  • (2 Pages)
  • +
  • 1
  • 2