Forum Discussion
dalton_stegner
5 years agoFrequent Visitor
Using Tabular ProviderDataSource with On Premise PowerBi Data Gateway DB Connection
I am attempting to use Microsoft.AnalysisServices.Tabular .NET library in an attempt to programmitcally generate a Tabular model in powerbi. I am able to upload my table structure just fine. My issue...
Anonymous
5 years agoNot applicable
Hi dalton_stegner,
Do you mean dynamic change connection data sources that created by your code?
If that is the case, you can change the steps to add some conditions or fully parameterize your connection string, then you can modify the parameters to dynamically change the target data source.
Initialize Datasource steps: (from the sample)
string dataSourceName = "SQL Server Data Source Example";
dbWithTable.Model.DataSources.Add(new ProviderDataSource()
{
Name = dataSourceName,
Description = "A data source definition that uses explicit Windows credentials for authentication against SQL Server.",
ConnectionString = "Provider=SQLNCLI11;Data Source=localhost;Initial Catalog=AdventureWorks2014;Integrated Security=SSPI;Persist Security Info=false",
ImpersonationMode = Microsoft.AnalysisServices.Tabular.ImpersonationMode.ImpersonateAccount,
Account = @".\Administrator",
Password = "P@ssw0rd",
});
Regards,
Xiaoxin Sheng
rogersmj_ali
5 years agoNew Member
Copying and pasting what is already in the documentation does not help. The problem is that the Power BI service is completely discarding our data source that we attach to the model in the code. It doesn't tell us why, it just discards it and then there is no data source attached to the model. Please read my other comment on this post for more details.