Qlik Community

Ask a Question

Integration, Extension & APIs

Discussion board where members can learn more about Integration, Extensions and API’s for Qlik Sense.

Announcements
3 Keynotes, 100+ Breakout Sessions, 1 New York Times bestseller, and you. QlikWorld Online, May 10-12: REGISTER NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
ingemarc
Contributor
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
Contributor
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...

yko
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
Contributor
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.

yko
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.