Current filter:
                                You should refresh the page.
                                  • Hi,

                                    I am trying to use the SQLDataSource component that has been added to the Winforms package in the last version of Devexpress to make it work as a query manager. Our idea is to provide the SQLDataSource component with the connection information and then open the Query Manager to design queries for the selected connection and then fill a XtraGrid with the results.

                                    I do something like this:

                                    1 - Create SQLDatasource and assign a connection (I provide the parameters)
                                    [C#]
                                    Dim dataadapter As SqlDataSource = New SqlDataSource Dim con As SqlDataConnection = New SqlDataConnection("connection", params) dataadapter.ConnectionParameters = params dataadapter.ConnectionName = "connection" dataadapter.Connection.CreateDataConnectionParameters() dataadapter.Connection.CreateConnectionString()
                                    2 - Open Query Manager and retrieve the query
                                    [VB.NET]
                                    DevExpress.DataAccess.UI.Sql.SqlDataSourceUIHelper.ManageQueries(dataadapter) dataadapter.Fill() For Each q As TableQuery In dataadapter.Queries dataadapter.RebuildResultSchema() mGeneratedQuery = q.GetSql(dataadapter.Connection.GetDBSchema()) Return True Next

                                    This is working ok, my problem is that I would like to allow to store the SQL querys and then load them in the Query Manager so the user can choose them in order to load the Grid or create new ones if he wants. I am able to load the queries with the following code:

                                    [VB.NET]
                                    For i As Integer = 0 To mQuerysObj.QueryList.Count - 1 If CType(mQuerysObj.QueryList(i), QueryMenuPoint).databaseID = selectedDB.mIdBBDD Then Dim tQuery As New CustomSqlQuery() tQuery.Name = CType(mQuerysObj.QueryList(i), QueryMenuPoint).queryName tQuery.Sql = CType(mQuerysObj.QueryList(i), QueryMenuPoint).query dataadapter.Queries.Add(tQuery) End If Next
                                    What we need now is the following: We need to allow the end-user to select the query we want to load the grid with, when I close the query manager I have a query list but I have no way to know wich one has selected the user. Is there a way to access the query manager dialogs or capture some kind of event to make this possible?

                                    I attach a file with the selection screen of the query manager. My need is that when I click Ok in that dialog I can know what query was selected.

                                    Thanks,

                                    Alexis.


                                1 Solution

                                Creation Date Importance Sort by
                                Hi Alexis,

                                Note that the "ManageQueries" dialog was designed to edit the queries of the SqlDataSource, it was not created for the query selection. So there is no way to get the selected query from this dialog. I suggest creating your own dialog for this purpose. For example, put a ListBox control for the query selection in this dialog and populate this ListBox with the queries that are added to the SqlDataSource.Queries collection. Let us know if you have any further questions regarding this.

                                • PROINTER 10.01.2015

                                  Ok, I see.

                                  The problem is that we are opening the Queries Manager to let the user create their own query and wanted to use the same dialog to manage the saved queries, I guess we will have to find a workaround.

                                • Vasily (DevExpress Support) 10.02.2015
                                  Hi Alexis,

                                  Use the SqlDataSourceUIHelper.AddQuery and SqlDataSourceUIHelper.EditQuery methods to execute query adding and editing wizards from your custom dialog. This way you will be able to achieve the same functionality as in the built-in "ManageQueries" dialog. Please do not hesitate to contact us if you need any further help with implementing such dialog.

                                • PROINTER 10.05.2015

                                  Hi again,

                                  Thanks, your suggestion worked for us. I have a quick new question, is there a way to fill a TableQuery object from an SQL sentence? I see we have the getSQL() method but we will be interested in the reverse one.

                                • Vasily (DevExpress Support) 10.05.2015

                                  Hi Alexis,

                                  To process your recent post more efficiently, I created a separate ticket on your behalf: T296891: How to fill a TableQuery with an SQL command. This ticket is currently in our processing queue. Our team will address it as soon as we have any updates.