Quantcast
Channel: DevExpress Support Center (Examples)
Viewing all articles
Browse latest Browse all 7205

How to bind a dashboard to a SQL database using SqlDataProvider

$
0
0

The following example demonstrates how to bind a dashboard to a SQL database using SqlDataProvider.

SqlDataProvider allows you to establish a connection to a data store by providing connection parameters and selecting required data by specifying a SQL query.

Question Comments

Added By: Isaque Lima at: 3/27/2014 12:35:19 PM    

Could you send me a example using a XmlFileConnectionParameters. I tried 2 ways to create a datasource, but I had problems in both.
The first one is this:
DataSet Ds = new DataSet();
Ds.ReadXml(cubeItem);
DataSource dSource = new DataSource(name, Ds.Tables[0]);

If I do this way my datasource has all the fields, but the XML saved from the dashboard does not contains the tag <DataConnections>.

The second one is this:
XmlFileConnectionParameters xmlCon = new XmlFileConnectionParameters(cubeItem);
DataConnection dc = new DataConnection(name,xmlCon);
SqlDataProvider sql = new SqlDataProvider(dc);
DataSource ds = new DataSource(name, sql);

This way the tag <DataConnection> is OK but my datasource has no fields.

I think that I must set ds.Data = Ds.Tables[0], but I can't do that, because if I do I received the following error "Additional information: Data cannot be assigned if a data provider is used".

Could send me a example with the right way to do that? Can I instead of use a XML file use a XML stream ?

thanks,

Added By: Andrew Aks (DevExpress) at: 3/28/2014 2:45:59 AM    

Currently, the DevExpress Dashboard does not support connecting to XML data files via SqlDataProvider. It is not possible to configure a connection to an XML file using a SQL query, and if you configure the connection via code, a SQL connection is required. We will update our documentation to highlight this. In the meantime you can retrieve data from XML files in code as demonstrated in the following example.

http://www.devexpress.com/Support/Center/Example/Details/E4857
Refer to the http://www.devexpress.com/Support/Center/Question/Details/Q503888 ticket to learn about the data serialization format used in the Dashboard Suite.

Added By: Isaque Lima at: 3/28/2014 11:28:15 AM    

My first approach was very similar to E4857, in this approach every thing works fine inside de dashboad editor, but when I saved the dashboard, to use in the dashboard web viewer, the xml, that is generated by the dashboard editor ,does not contain the dataConnections tag. If I create a new XML datasource using the button "New Data Source" on the application example every thing works fine. I want to know how the XML datasource is created when I use this button, because I want to create by coding, not in the UI.

Added By: Andrew Aks (DevExpress) at: 3/30/2014 11:22:52 PM    

I have extracted our conversation into a separate thread:
http://www.devexpress.com/Support/Center/Question/Details/Q468535
Let's continue our discussion there.


Viewing all articles
Browse latest Browse all 7205

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>