使用System.Configuration.ConfigurationManager类在app.config获取连接字符串
using System;
using System.Data;
using System.Data.SqlClient;
using System.Text;
using System.Configuration;
static void Main(string[] args)
{
string strCn;
//Get the connection string on app.config
strCn = ConfigurationManager.ConnectionStrings["ConsoleAppBooksMgr.Properties.Settings.BooksMgrConnectionString"//ConnectionStringName].ToString();
Console.WriteLine(strCn);
}
浙公网安备 33010602011771号