Forum Discussion
Using Tabular ProviderDataSource with On Premise PowerBi Data Gateway DB Connection
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_ali5 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.
- dalton_stegner5 years agoFrequent Visitor
Sorry to clarify on top of your sample code, I mean how could I create a connection string for a ProviderDataSource for a PowerBI Gateway? My issue stems from powerbi not being able to connect to my database since powerbi is outside the vpn of our database hosted in Azure. All samples I have found are for local host which is not my use case. Or is my only option to expose a database with a user account and allow that account to log in.