Spring.net 获取SQL连接字符串
Spring.Context.IApplicationContext ctx = Spring.Context.Support.ContextRegistry.GetContext(); IBatisNet.DataMapper.SqlMapper sqlMap = (IBatisNet.DataMapper.SqlMapper)ctx.GetObject("sqlMap"); string conString = sqlMap.DataSource.ConnectionString; using (System.Data.SqlClient.SqlConnection conn = new System.Data.SqlClient.SqlConnection(conString)) { conn.Open(); string cmdText = "SELECT 1"; System.Data.SqlClient.SqlCommand cmd = new System.Data.SqlClient.SqlCommand(cmdText, conn); cmd.ExecuteNonQuery(); }