CoBikeJunkie
CoBikeJunkie

Reputation: 89

Supplied connections must be of type AstDbConnectionNode

I have been working on a simple BIML solution to start learning how to use it. I keep getting an error message:

Supplied connections must be of type AstDbConnectionNode for this method. at Varigence.Biml.Extensions.ExternalDataAccess.GetDatabaseSchema in :line 0

I've been searching and trying different solutions and have not found an answer yet. So, I'm turning to everyone here. I need another set of eyes on this so I can figure out what I'm doing wrong.

My first BIML file has my connection setup to World Wide Importers on my local box.

<Biml xmlns="http://schemas.varigence.com/biml.xsd">

<#@ template language = "C#" tier="0" #>

<Connections>
<OleDbConnection
    Name="src" 
    ConnectionString="Data Source=localhost\SQL16;Initial Catalog=WorldWideImporters;Provider=SQLNCLI11.1;Integrated Security=SSPI;" 
    CreateInProject = "true">
</OleDbConnection>
</Connections>

<Databases>
    <Database Name="src" ConnectionName = "src" />
</Databases>

Second BIML file is what is throwing the error

<Biml xmlns="http://schemas.varigence.com/biml.xsd">

<#@ template language = "C#" tier = "1" #>
<#@ import namespace="Varigence.Biml.CoreLowerer.SchemaManagement" #>

<# var srcDB = RootNode.OleDbConnections["src"]; #>
<# var WWIdb = srcDB.GetDatabaseSchema(ImportOptions.ExcludeViews); #>

<Packages>
    <# foreach (var table in WWIdb.TableNodes) { #>
    <Package Name="<#=table.Schema#>_<#=table.Name#>"     ConstraintMode="Linear">
        <Tasks>
            <Dataflow Name="DF Copy <#=table.Name#>">
            </Dataflow>
        </Tasks>
    </Package>
    <# } #>
</Packages>
</Biml>

Upvotes: 3

Views: 983

Answers (1)

billinkc
billinkc

Reputation: 61211

That, misleading, error surfaces from the call to GetDatabaseSchema I say it's misleading because the root problem is that srcDB is null. See for yourself by using this code in your second Biml file.

<#@ import namespace="System.Windows.Forms" #>
<#@ assembly name= "C:\Windows\Microsoft.NET\Framework\v4.0.30319\System.Windows.Forms.dll" #>
<# var srcDB = RootNode.OleDbConnections["ConnectionDoesNotExist"]; #>
<#
    if (srcDB == null)
    {
        MessageBox.Show("It's null");
    }
    else
    {
        MessageBox.Show("It's not null - {0}", srcDB.Name);
    }
#>

Root problem

You are access an object in the connections collection that doesn't exist - probably because while you have your tiering correct, you need to "include" all the files when you build.

How do you resolve this?

If you're using BimlExpress or BIDS Helper then you simply need to select both file1.biml and file2.biml in the solution menu and right click to generate package.

If you are using Mist/BimlStudio, then I would just right click on file1.biml and change that to Convert to Live BimlScript.

Upvotes: 1

Related Questions