我在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");
#>
是否可以不重复连接字符串和引用&#34; MyConn&#34;直接在Bimlscript?我的意思是:
<#
DataTable = MyTable;
MyTable = ExternalDataAccess.GetDataTable(MyConn,"SELECT * from dbo.MyTable");
#>
谢谢, 齐亚德
答案 0 :(得分:2)
目前是移动设备,但代码大致
ExternalDataAccess.GetDataTable((AstDbConnectionNode)RootNode.Connections["MyConn"],"SELECT * ...);
这假定连接管理已按照我所讨论的on my other answer
进行了定义您还可以通过RenderedConnectionString属性
从连接对象访问连接字符串