Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
ingemarc
Partner - Contributor
Partner - Contributor

Data Connections & .Net SDK

Hi,

I found the Connection and ConnectionInfo classes in the Qlik.Engine namespace, but how do I use them to retrieve

-The list of connections in an app

-The list of all connections

And how do I create a new custom connection in an app?

4 Replies
ingemarc
Partner - Contributor
Partner - Contributor
Author

OK I figured out how to get the connections in an app.

Something like this:

            IAppIdentifier selectedAppIdentifier = location.AppWithNameOrDefault(listBox1.SelectedItem.ToString());

            IApp application = location.App(selectedAppIdentifier);

            foreach (IConnection connectionInfo in application.GetConnections())

            {

                listBox2.Items.Add(connectionInfo.Name);

            }

But I am still trying to figure out how to create new connections from scratch, and I don't mean just to add the connect statement in the script. I need to create actual custom connections with their stored properties...

Øystein_Kolsrud
Employee
Employee

You'll need to go through the Repository API to do that kind of operations. Have a look at this one:

Data connection: Create ‒ Qlik Sense Developers

ingemarc
Partner - Contributor
Partner - Contributor
Author

Thanks. I may have to eventually use the repository API, but I would really prefer to solve this with the .Net SDK. Actually this finally did the trick for me with the .Net SDK:

            IAppIdentifier selectedAppIdentifier = location.AppWithNameOrDefault(listBox1.SelectedItem.ToString());

            IApp application = location.App(selectedAppIdentifier);

            Connection connection = new Connection

            {

                Name = textBoxConnectionName.Text,

                ConnectionString = textBoxConnectionString.Text,

                Type = textBoxConnectionType.Text,

                Password = textBoxPassword1.Text

            };

            application.CreateConnection(connection);

But I am only prototyping with Qlik Sense Desktop and will eventually need this to work in a server environment. Is there any reason why this wouldn't work in the Server? BTW the connections are of CUSTOM CONNECT type.

Øystein_Kolsrud
Employee
Employee

Nice! I wasn't aware of that method. One learns something new every day on Qlik Community 🙂

I can't see anything that suggests that it can't be used in a server environment, but then again, since the method is obviously new to me, perhaps someone else can chime in.