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. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Using a SQL Server stored procedure

Thread ID:





131216 Jun 28,2017 03:57 PM UTC Jun 29,2017 01:56 PM UTC ASP.NET MVC 1
Tags: Chart
Michael Easterbrook
Asked On June 28, 2017 03:57 PM UTC

Can I use a SQL Server stored procedure as the data source for a chart? For example:

var db = Database.Open("BITool");

var data = db.Query("Exec SalesOps.AccountOrders @Account=@0", App.AccountListID);

var myChart = new Chart(width: 835, height: 200, themePath: "chartThemeYellow.xml")

.AddTitle("Account Medical Orders")


xValue: data, xField: "Segment",

yValues: data, yFields: "Orders")



Dharanidharan Dharmasivam [Syncfusion]
Replied On June 29, 2017 01:56 PM UTC

Hi Michael, 

Thanks for contacting Syncfusion support. 

We have analyzed your query. Yes, you can able to use SQL stored procedure as data source for chart. We have prepared a sample, in which in ajax request of load event, we have bind the data source to chart as depicted in the below code snippet. 


Stored procedure: 

CREATE PROCEDURE [dbo].[ChartData] 
              SELECT * FROM Orders  
RETURN 0          

View page: 

function chartLoad(sender) { 
            type: "POST", 
            url: '@Url.Action("DataSource", "Home")', 
            async: false, 
            success: function (data) { 
                sender.model.series = []; 
                sender.model.series.push({ dataSource: data.result, xName: "OrderID", yName: "EmployeeID", type: "line" }); 
public ActionResult DataSource(DataManager dm) 
            DataOperations operation = new DataOperations(); 
            DataTable dt = new DataTable("Order"); 
            string constring = ConfigurationManager.ConnectionStrings["NORTHWNDConnectionString"].ConnectionString; 
            using (SqlConnection con = new SqlConnection(constring)) 
                using (SqlCommand cmd = new SqlCommand("ChartData", con)) 
                    SqlDataReader dr = cmd.ExecuteReader(); 
                    // Load into the dataTable 
            //Convert the dataTable into list 
            List<EditableOrder> resList = new List<EditableOrder>(); 
            return Json(new { result = resList }, JsonRequestBehavior.AllowGet); 

Here we have bind all the data, you can change this with respect to this scenario. 


Sample for reference can be find from below link. 
Find the steps below to create stored procedure. 
Step 1: Click on the Server Explorer, then click on the required db on which you need to create stored procedure and right click on the Store Procedures and create as depicted in the above code snippet. 
Step 2: Click on the Update to reflect back in original db. 


Kindly revert us, if you have any concern. 



This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

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

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