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(); }
欢迎转载,转载请注明:转载自[ http://www.cnblogs.com/zjfree/ ]