Ziad Salem
Ziad Salem

Reputation: 525

Reference a Biml connectionString in Bimlscript (C# Control Nuggets)

I have a connection in Biml:

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

I have also a c# control nuggets code to get a data table from the database (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");
#>

Is it possible not to repeat the connection string and reference "MyConn" directly in Bimlscript? I mean something like:

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

Thanks, Ziad

Upvotes: 1

Views: 967

Answers (1)

billinkc
billinkc

Reputation: 61211

Mobile at the moment but code approximately

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

This assumes that the connection manage had been defined as I discussed on my other answer

You can also access the connection string from a connection object though the RenderedConnectionString property

Upvotes: 2

Related Questions