Qlik Community

Qlik Sense Integration, Extensions, & APIs

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

ingemarc
New 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?

Tags (1)
4 Replies
ingemarc
New Contributor

Re: Data Connections & .Net SDK

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

Employee
Employee

Re: Data Connections & .Net SDK

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
New Contributor

Re: Data Connections & .Net SDK

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.

Employee
Employee

Re: Data Connections & .Net SDK

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.