0

I have an application which uses Sql Server Express Edition to store data. I have a database with 8-10 tables in it. I have mdf and ldf file with me. Now i want to install my application in some other computer, then how to deploy my database with my installation files (assuming the other computer already have Sql Server with them). Can i use my mdf and ldf files, or i need to create my database and tables again programatically during installation of my Application.

I am a newbie, please guide me. I am using .Net framework 4.0 and Visual Studio Professional Edition.

Andrew Barber
  • 39,603
  • 20
  • 94
  • 123
Sandy
  • 11,332
  • 27
  • 76
  • 122

1 Answers1

1

SQL Server Express runs out-of-process, so your application does not control the data files. You have to submit your application data to SQL Server via data statements, replication, or whatever, and SQL Server gets to decide what to do with them.

You may be able to submit an .mdf directly to SQLS Express via an AttachDBFilename connection string, I have not tried this.

If you used an embedded database like SQL Server Compact you would be able to include the data along with your application. Whether this is a better solution depends on what else you are doing with your database.

Dour High Arch
  • 21,513
  • 29
  • 75
  • 90
  • may i know how to embed my database in my application – Sandy Sep 08 '11 at 16:14
  • SQL Server CE creates standalone .sdf files. You can embed files in your application by adding them as a resource to an assembly file, by adding files to your Setup project in Visual Studio, or by adding the SQL to create the files as a resource or in your project file. Each option has different outcomes; which is best for you depends on what you are trying to do. – Dour High Arch Sep 08 '11 at 19:00