开发者

Access a accdb file (MS Access 2007) from resources

probably this is a simple question but because i have never used resources like that i can not think how should i do it. I am writing a very simple program that connects to a accdb file (Microsoft Access 2007 file) and returns some results in a datagridview. Everything is fine. Now because we have to deploy this program in many computers i publish it so everyone we w开发者_开发知识库ant can install it and have updates. What i wanted to do is to make the database file part of the program which i did it by adding it to the resources. My problem is that i do not know what connection string to enter in order to access it in my resources. My previous connectionstring before i deploy it was this

ConnectionString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\bl.accdb;Persist Security Info=True

What should i change in the data source in order to access the same file in my resources? Or am i wrong and this is not possible? Thanks


You can do it. All you need to do is point the datasource to the location of the resources direcory, which by default is adjacent to the application itself. You could determine this at runtime by using:

Application.StartupPath & "\Resources\DatabaseName.accdb"
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜