Incrustar la base de datos SQL Server CE en una aplicación C #

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?

Gracias de antemano.

preguntado el 27 de agosto de 11 a las 21:08

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 -

1 Respuestas

Podrías agregar el .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.

Respondido 28 ago 11, 01:08

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

@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? - Jethro

To tell you the truth both of'em. First one to be more portable and second one for more security - Amir

@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. :) - Jethro

No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas or haz tu propia pregunta.