在Bimlscript中引用Biml connectionString(C#Control Nuggets)

问题描述 投票:1回答:1

我在Biml有一个连接:

<Connections>
        <OleDbConnection Name="MyConn" ConnectionString="Data Source=localhost;Initial Catalog=MyDB;Provider=SQLNCLI11.1;Integrated Security=SSPI;Auto Translate=False;" CreateInProject="true"/>
</Connections>

我还有一个c#控件块代码来从数据库(MyDB)获取数据表:

<#
    string ConnectionString = "Data Source=localhost;Initial Catalog=MyDB;Provider=SQLNCLI11.1;Integrated Security=SSPI;Auto Translate=False;";
    DataTable MyTable;
    MyTable = ExternalDataAccess.GetDataTable(ConnectionString,"SELECT * from dbo.MyTable");
#>

是否有可能不重复连接字符串并直接在Bimlscript中引用“MyConn”?我的意思是:

<#
DataTable = MyTable;    
MyTable = ExternalDataAccess.GetDataTable(MyConn,"SELECT * from dbo.MyTable");
#>

谢谢,齐亚德

c# ssis connection-string sql-server-data-tools biml
1个回答
2
投票

目前移动但代码大致

ExternalDataAccess.GetDataTable((AstDbConnectionNode)RootNode.Connections["MyConn"],"SELECT * ...);

这假设连接管理已经定义为我讨论的on my other answer

您还可以通过Rendered ConnectionString属性从连接对象访问连接字符串

© www.soinside.com 2019 - 2024. All rights reserved.