1
votes

Can a DevExpress XtraGrid be filled using a a Dynamic SELECT statement string?

i.e. SELECT * FROM Employee
or
SELECT * FROM Dependents

To fill our XtraGrids currently, we use a ORM that creates entities. To do this it takes a lot of steps and time. What is driving me to ask this question is we do a lot of client aquistions where we get hundreds of files. I do not want to create entities for all of these then have to create an XtraGrid for each entity. Ideally if I can just feed it a SELECT statement and the XtraGrid could render it then I could use the XtraGrid very nice data minipulation features (Filter, Group By, etc).

If you have any other ideas or suggestions please do not hesitate to post them.

Revised:
Per Brendon's responce below to create a static method that returns a DataTable.
Here is a link to a page that actually does that. http://msmvps.com/blogs/deborahk/archive/2009/07/07/dal-retrieve-a-datatable-using-a-sql-statement.aspx

1

1 Answers

2
votes

The XtraGrid doesn't have any built-in mechanisms to create a data source from a SQL statement. For me, the easiest way to accomplish this is to simply create a static method that builds and returns a DataTable/DataSet from a SQL statement. I can then set the XtraGrid's data source to the results of this method.