4 Replies Latest reply: Dec 11, 2017 2:54 AM by Øystein Kolsrud RSS

    Data Connections & .Net SDK

    Ingemar Carlo

      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?

        • Re: Data Connections & .Net SDK
          Ingemar Carlo

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

            • Re: Data Connections & .Net SDK
              Øystein Kolsrud

              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

                • Re: Data Connections & .Net SDK
                  Ingemar Carlo

                  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.