如何使用本地数据库.sdf部署.exe? [英] How to deploy .exe with local database .sdf?

查看:58
本文介绍了如何使用本地数据库.sdf部署.exe?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Hello !!
I am using below statement to connect with database and already include MyDB.sdf file in Application folder of my windows installer.

SqlCeConnection con = new SqlCeConnection("Data Source="+ System.IO.Path.Combine(Path.GetDirectoryName(System.Reflection.Assembly.GetEntryAssembly().Location), "MyDB.sdf"));

After build My .exe when i run it using shortcut on desktop, 
application working is stopped. why?

Thank you

推荐答案

使用 DataDirectory 标记: https://social.msdn.microsoft.com/Forums/sqlserver/en-US/0712dd47-8437-4c84-b27e-2b12fddf2153/what-is-the-datadirectory-in-data -source-datadirectorynorthwindsdf?forum = sqlce [ ^ ]


这篇关于如何使用本地数据库.sdf部署.exe?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆