动软代码生成器三层用于winform
DBUtility项目中的DbHelperSQL.cs (找自己对应的数据库类型)
修改前20行中的数据库连接字符串获取方式为:
//数据库连接字符串(web.config来配置),多数据库可使用DbHelperSQLP来实现.
// public static string connectionString = PubConstant.ConnectionString;
//配置winform的获取方法
public static string connectionString = System.Configuration.ConfigurationManager.ConnectionStrings[ "ConnectionString" ].ToString();
|
并在应用层添加app.config
<?xml version="1.0"?> <configuration> <configSections> </configSections> <connectionStrings> <add name="ConnectionString" connectionString="Data Source=server;Initial Catalog=Database;User ID=sa;Password=sa" providerName="System.Data.SqlClient"/> </connectionStrings> <startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/></startup> <runtime> <legacyUnhandledExceptionPolicy enabled="true"/> </runtime> </configuration>