Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
105
read the sql statement at runtime
posted

Hi,

It is possbile to get de SQL statement at runtime?

thanks!!

  • 105
    Verified Answer
    posted

    yes, it is possible!!

    here the code:

                    var ns = "{http://schemas.infragistics.com/xaml/reports}";

                    var document = XDocument.Load(path_igr);

                    var reportDataSources = document.Descendants(ns + "SqlDataSource").Select(ds => new
                    {
                        Name = ds.Attributes("Name").First().Value,
                        ConnectionStringKey = ds.Attributes("ConnectionName").First().Value,
                        QueryText = ds.Descendants(ns + "Query").Attributes("CommandText").First().Value,
                        Fields = ds.Descendants(ns + "SqlDataSource.Fields").Elements().Select(field =>
                            new
                            {
                                DataField = field.Attribute("DataField").Value,
                                Name = field.Attribute("Name").Value,
                                FieldTypeString = field.Attribute("FieldTypeString").Value
                            }),
                        Parameters = ds.Descendants(ns + "SqlDataSource.Parameters").Elements().Select(field => field.Attribute("Name").Value)
                    });

                    foreach (var dataSource in reportDataSources)
                    {
                        MessageBox.Show(dataSource.QueryText, "SQL", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }

    Thanks!!