App.config加入此代码 

<connectionStrings>
<add name ="connStr" connectionString="server=.;uid=sa;pwd=sa;database=t_DB"/>
</connectionStrings>


DBHelper所在的层需要添加引用using System.Configuration;(三个的上边)

DBHelper添加连接字符串    写:

public static string connStr = ConfigurationManager.ConnectionStrings["connStr"].ConnectionString;