2

I'm developing a program which uses SQL Server Compact Edition for processing data. We all know that this creates a .sdf file in output (SQL Server CE database File).

My question is if there is anyway to embed this .sdf file into the executable?

Thanks in advance.

1
  • 1
    for that to be possible it would need to be read only I suppose. Are you asking because you want to distribute only the exe? One way I can imagine is to put the sdf inside as a "filestream" ressource, then when your application runs the first thing is to load the filestream from the assembly and write it to a temp.sdf and load that one Commented Aug 27, 2011 at 21:27

1 Answer 1

1

You could add the .sdf file to a Resources File .resx and then when your application starts you can just copy it out of your Resources and create it, if it doesn't already exist.

Sign up to request clarification or add additional context in comments.

4 Comments

If you mean that application do this for the first time I think it won't be a good way, But if you mean that application Extract it on load and Update resource file on exit, is it possible?? as Cilvic said I think it's read-only
@Amir, are you trying to do this so you only have one exe to distribute? Or do you physically want the db to be part of the exe?
To tell you the truth both of'em. First one to be more portable and second one for more security
@Amir, well the first part is possible, second part isn't and if you worried about security then all you need to do is set a username and password on your database. There are other more advanced features you can look at for database security but I don't think you should worry about that. Let the database handle the encryption and security, you just worry about the programming. :)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.