Question

I want my users not to be able to see the MS Access *.accdb Database I am using. Therefore would I like to embed it into the assembly. How should I do this?

My guess is to modify the connection string.

The connection to the database has been automatically made with the import wizard. The connection string can be found in the file Settings.Designer.vb and has been written like this:

Global.System.Configuration.ApplicationScopedSettingAttribute(), _
Global.System.Diagnostics.DebuggerNonUserCodeAttribute(), _
Global.System.Configuration.SpecialSettingAttribute(Global.System.Configuration.SpecialSetting.ConnectionString), _
Global.System.Configuration.DefaultSettingValueAttribute("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=|DataDirectory|\MyDatabase.accdb;" & "Persist Security Info=True")

Is there a way I could change Data Source=|DataDirectory|\MyDatabase.accdb (last line, scroll right) to something else?

I found an article on how embed resources, but they seem not to apply to a connection string. Furthermore, it seems that (at least in 2008), to access an MS Access Database, it had to be taken out of its embedded state. This would make useless this embedding in my program.

Any help greatly appreciated.

Was it helpful?

Solution

I confirm: to try to embed a database into an assembly does not make sense if the purpose is to hide it.

As an assembly is a static structure, no bit can be changed in it. So something as dynamic as a database definitely has to be taken out of the assembly before it can be used.

In order my users not to see the database I am using, I opted for the solution to copy it into the &AppData& directory. Not very secure (despite the password protection) but at least not obvious.

Have a look at this answer to see how.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top