cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
IDBdesign
Frequent Visitor

Dynamic Database Selection in Execute a SQL Query

Hi all,

I am currently working on an PowerApp for editing a certain table that is common between several of our databases. 

I need to be able to specify, through the PowerApp, which database (chosen from a list) to connect to and pull data from.  Unfortunately Execute a SQL Query (V2) doesn't seem to like dynamic parameters for the Database input and tells me the datasource is invalid.

My question is.. is there any way to do this?  Specifying the database to connect to as a parameter for the flow at runtime.

1 ACCEPTED SOLUTION

Accepted Solutions
Pstork1
Dual Super User
Dual Super User

There is no support at this point for dynamic selection of the database, since it is used to create the connector.  The only workaround I've seen is to use a switch that keys off the database and then use multiple connectors pre-configured for each database.  When you select a specific database it switches to a parallel path that uses the appropriate connection.



-------------------------------------------------------------------------
If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.

View solution in original post

4 REPLIES 4
Pstork1
Dual Super User
Dual Super User

There is no support at this point for dynamic selection of the database, since it is used to create the connector.  The only workaround I've seen is to use a switch that keys off the database and then use multiple connectors pre-configured for each database.  When you select a specific database it switches to a parallel path that uses the appropriate connection.



-------------------------------------------------------------------------
If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.

Hi @Pstork1, thank you for your response.

 

I am trying to achieve the method you described in your response using the switch statement, however I am having trouble using more than one connection.  Are multiple SQL connections not supported?

Sorry, I used the wrong terminology.  Assuming you are hitting the same server and the same database you only need one connection.  But you would create multiple Actions in parallel paths in the switch statement.

 

screenshot.png



-------------------------------------------------------------------------
If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.

@Pstork1  You had it right initially lol.  I was hitting the same server but different databases.

Figured it out though.  You can click the vertical ellipsis on the side of the Execute a SQL Query action to change the connection.

 

Appreciate your help 🙂

Helpful resources

Announcements
Power Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

New Ideas Forum MPA.jpg

A new place to submit your Ideas for Power Automate

Announcing a new way to share your feedback with the Power Automate Team.

MPA Virtual Workshop Carousel 768x460.png

Register for a Free Workshop

Learn to digitize and optimize business processes and connect all your applications to share data in real time.

365 EduCon 768x460.png

Microsoft 365 EduCon

Join us for two optional days of workshops and a 3-day conference, you can choose from over 130 sessions in multiple tracks and 25 workshops.

Users online (3,533)