我在 Biml 中有一个连接:
<Connections>
<OleDbConnection Name="MyConn" ConnectionString="Data Source=localhost;Initial Catalog=MyDB;Provider=SQLNCLI11.1;Integrated Security=SSPI;Auto Translate=False;" CreateInProject="true"/>
</Connections>
我还有 ac# control nuggets 代码来从数据库(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");
#>
谢谢,齐亚德