---------------------- Windows Phone 7手机开发、.Net培训、期待与您交流! ----------------------
在winform中连接数据库必须在Main函数中加上以下代码,WEB中则不需要;
string dataDir = AppDomain.CurrentDomain.BaseDirectory;
if (dataDir.EndsWith(@"\bin\Debug\") || dataDir.EndsWith(@"\bin\Release\"))
{
dataDir = System.IO.Directory.GetParent(dataDir).Parent.Parent.FullName;
AppDomain.CurrentDomain.SetData("DataDirectory", dataDir);
}
---------------------- Windows Phone 7手机开发、 .Net培训、期待与您交流! ----------------------详细请查看: http://net.itheima.com/
本文介绍在WinForm应用程序中连接数据库的一种方法,通过设置AppDomain的数据目录来定位数据库文件的位置,确保程序可以正确加载数据。
381

被折叠的 条评论
为什么被折叠?



