我在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");
#>
谢谢,齐亚德
目前移动但代码大致
ExternalDataAccess.GetDataTable((AstDbConnectionNode)RootNode.Connections["MyConn"],"SELECT * ...);
这假设连接管理已经定义为我讨论的on my other answer
您还可以通过Rendered ConnectionString属性从连接对象访问连接字符串