How to connect my RadHtmlChart with SQL data

78 views Asked by At

I want to make a bar chart in Visual Studio. The data I want to display is in SQL. When I configure the data source it asks me to 'Specify a custom SQL statement or stored procedure'. I put this code into it

SELECT 'A' AS STATUS, COUNT(*) AS A FROM TABLE1
WHERE VALIDATED = 'Y'
GROUP BY 1
UNION
SELECT 'B' AS STATUS, COUNT(*) AS B FROM TABLE2
WHERE RESOLVED = 'N'
GROUP BY 1
UNION
SELECT 'C' AS STATUS, COUNT(*) AS C FROM TABLE1
GROUP BY 1

and when I test the query it doesn't work. I have also tried saving a new table in SQL and connecting to the table but that also doesn't work.

Do you know why my code isn't working or how to make my chart work?

Thanks

1

There are 1 answers

0
JM1 On

It's my understanding you will need a dataset that has the columns pulling the data you need, and you would reference those columns in your RadHTMLChart.

You can add a sqldatasource to your html, and add it to the RadHtmlChart.

One of the properties is DataSourceID, just set it equals to the name of your datasource, like this: DataSourceID="sqldatasource name".

Then, on your LineSeries for example, you have the option of DataFieldY, set that to your Y series column name you are pulling from SQL.

On your X axis, there is a DataLabelsField, you can set that to the column you have in SQL for your X axis.

If this doesn't make sense, let me know.