We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Change the dashboard connection on demand for non .NET applications using the Web services/Web api

Platform: Dashboard Platform |
Control: Dashboard SDK

Change connection string for non .NET applications

Change Connection string enables you to switch the data from one server to another. This can be achieved through the onApplyConnection API.

To use the change connection string in the application that are not .NET, follow the given steps:

  1. Create a WCF Service/Web API to get the encrypted connection (modified) string to your application. Refer to MSDN for creating a WCF Service or refer to the following link for creating a web API.




  1. Add the Syncfusion.Dashboard.Encryption.dll to the WCF service/Web API, which is shipped in the following location in your WCF project.


%localappdata%\Syncfusion\Dashboard Platform SDK\Getting Started Samples\Common\Precompiled Assemblies



  1. Add the Newtonsoft.JSON dll to the WCF service/Web API, you can download it from the given link https://www.nuget.org/packages/newtonsoft.json/10.0.3.



  1. Add the following code to pass the encrypted connection string in the Service.cs file. 


using System; 
using System.Collections.Generic; 
using Syncfusion.Dashboard.Encryption; 
using Syncfusion.Dashboard.Encryption.Connection; 
namespace WcfService 
The below service is for demo purpose, user can have defined on their own.     
    public class MyService : IMyService 
        public string GetModifiedConnectionString() 
            DashboardCryptoProvider provider = new DashboardCryptoProvider(EncryptionType.AES); 
            Connection connection = new Connection { DataSources = new List<DataSourceConnectionString>() }; 
            ConnectionStringGenerator generator = new ConnectionStringGenerator(); 
            ConnectionParameters connectionParameter1 = new ConnectionParameters 
                AuthenticationType = 1, //Server or Windows Authentication Type. Mostly on demand connection should be Server Authentication. 
                ServerName = ".", //Your Target Server name 
                UserName = "**", // Your Target server credential 
                Password = "**",  
                Database = "NORTHWND" //Your target server database name 
            connection.DataSources.Add(new DataSourceConnectionString 
                Name = "DataSource1", 
                ConnectionString = generator.GetConnectionString(connectionParameter1, ConnectionProviderType.SqlServer, OdbcDbmsType.None) 
            return provider.DoEncryption(Converter.SerializeObject(connection)); 
    public class Connection 
        public List<DataSourceConnectionString> DataSources { get; set; } 
    public class DataSourceConnectionString 
        public string Name { get; set; } 
        public string ConnectionString { get; set; } 
        public DataSourceConnectionString() 
            Name = string.Empty; 
            ConnectionString = string.Empty; 


The above code snippet can be used for the SQL data source. For other data sources, refer to the following UG to learn the connection parameter need to be passed to generate the connection string





  1. Compile and publish the dashboard service at IIS. Refer to how to host the WCF in IIS. https://docs.microsoft.com/en-us/dotnet/framework/wcf/feature-details/how-to-host-a-wcf-service-in-iis


  1. Get the encrypted connection string from the WCF Service and bind it in the onApplyConnection event of your PHP sample by using the AJAX POST method. Refer to the following code snippet.


             require_once 'EJ/AutoLoad.php'; 
             $dashboardviewer=  new EJ\DashboardViewer("dashboard"); 
             $size= new EJ\DashboardViewer\Size(); 
             echo $dashboardviewer ->serviceUrl("http://dashboardsdkdemo.syncfusion.com/DashboardService/DashboardService.svc")->dashboardPath("http://dashboardsdkdemo.syncfusion.com//Dashboards//Server.sydx")->filterParameters("location.search.substr(1)")->size($size)->dashboardCreated("dashboardCreated")->onApplyConnection("OnApplyConnection")->render(); 
function OnApplyConnection(sender) { 
                type: "GET", 
                contentType: "text/xml; charset=utf-8", 
                async: false, 
                url: "http://localhost:port/Service1.svc/GetModifiedConnectionString",  // Replace your WCF Service URL 
                success: function (result) { 
                    var modifiedConnectionString = result["GetModifiedConnectionStringResult"]; 
                    sender.data.modifiedConnectionStrings = JSON.stringify(modifiedConnectionString); 


If you want the above PHP code snippet in the Javascript/ASP.NET MVC/Angular, refer to the following link.


You must log in to leave a comment

Please sign in to access our KB

This page will automatically be redirected to the sign-in page in 10 seconds.

Up arrow icon

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

Live Chat Icon For mobile