开发者论坛

 找回密码
 注册 (请使用非IE浏览器)
查看: 4282|回复: 1

XAF 数据库连接

[复制链接]

0

精华

0

贡献

0

赞扬

帖子
4
软币
95
在线时间
2 小时
注册时间
2013-10-16
发表于 2014-2-19 14:21:03 | 显示全部楼层 |阅读模式
XAF 数据库连接如何代码实现,不用设计器拖拉(客户端配置数据库连接)?
回复

使用道具 举报

0

精华

677

贡献

767

赞扬

帖子
273
软币
11235
在线时间
1122 小时
注册时间
2013-6-9
发表于 2014-2-19 15:45:13 | 显示全部楼层
XAF 连接数据库使用的是一个字符串。默认是在app.config或者web.config中。
以下是一个实例:
  1.         static void Main()
  2.         {
  3. #if EASYTEST
  4.             DevExpress.ExpressApp.Win.EasyTest.EasyTestRemotingRegistration.Register();
  5. #endif
  6.             //Thread.CurrentThread.CurrentUICulture = new CultureInfo("zh-CN");
  7.             //Thread.CurrentThread.CurrentCulture = new CultureInfo("zh-CN");
  8.             Application.EnableVisualStyles();
  9.             Application.SetCompatibleTextRenderingDefault(false);
  10.             EditModelPermission.AlwaysGranted = System.Diagnostics.Debugger.IsAttached;
  11.             WsdSolution1WindowsFormsApplication winApplication = new WsdSolution1WindowsFormsApplication();
  12.             // Refer to the http://documentation.devexpress.com/#Xaf/CustomDocument2680 help article for more details on how to provide a custom splash form.
  13.             //winApplication.SplashScreen = new DevExpress.ExpressApp.Win.Utils.DXSplashScreen("YourSplashImage.png");
  14.             if (ConfigurationManager.ConnectionStrings["ConnectionString"] != null)
  15.             {
  16.                 winApplication.ConnectionString = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;
  17.             }
  18. #if EASYTEST
  19.             if(ConfigurationManager.ConnectionStrings["EasyTestConnectionString"] != null) {
  20.                 winApplication.ConnectionString = ConfigurationManager.ConnectionStrings["EasyTestConnectionString"].ConnectionString;
  21.             }
  22. #endif
  23.             try
  24.             {
  25.                 winApplication.Setup();
  26.                 winApplication.Start();
  27.             }
  28.             catch (Exception e)
  29.             {
  30.                 winApplication.HandleException(e);
  31.             }
  32.         }
复制代码

评分

参与人数 1赞扬 +1 收起 理由
maple + 1 赞一个

查看全部评分

回复

使用道具 举报

Archiver|手机版|小黑屋|开发者网 ( 苏ICP备08004430号-2 )
版权所有:南京韵文教育信息咨询有限公司

GMT+8, 2024-5-6 00:09

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表