Wouldn't it be great....

If there was a way to use TSQL syntax to query against a loaded DataSet? Something like:

Dim Settings As New DataSet
Settings.ReadXml("..\settings.xml", XmlReadMode.InferSchema)
Dim result As New DataTable = Settings.Query("SELECT * FROM Tables(0) WHERE Row.Item('Default') = FALSE")
SomeDataGrid.DataSource = result
SomeDataGrid.DataBind

Man, I think that would be neat. Anybody know if you can do this today?

5 Comments

  • Not really what you're looking for, but the closest you can get to that, that I know of is using the Select method on the DataTable object. It returns an array of DataRow objects though.

  • You can get the same result by using a dataview, or like th eprevious poster said by using select on the Datatable.



    You can do it its just not as stright foward.



    DataRow[] foundRows =

    Sessings.Tables[0].Select( "Default='FALSE'", "", DataViewRowState.Modified );

  • I've used the RowFilter to that kind of effect.



    PtDs = getTodaysPatients();

    DateTime dteSelDate = (DateTime)ViewState["FetchDate"];

    if(PtDs.Tables.Count > 0)

    {

    DataView PtDv = PtDs.DefaultViewManager.CreateDataView(PtDs.Tables[0]);

    PtDv.Sort = ViewState["ClinSortColumn"].ToString() + " " + ViewState["ClinSortOrder"].ToString();

    PtDv.RowFilter = (string)ViewState["ClinFilterValue"];

    dgTodaysPts.EditItemIndex = int.Parse(ViewState["EditItemIndex"].ToString());

    dgTodaysPts.DataSource = PtDv;

    dgTodaysPts.DataBind();

    }


  • whoops, where (string)ViewState["ClinFilterValue"] equals a where clause. "clinic='MO' AND physicianId=3214"

  • Yes, I was dreaming of the same thing just yesterday. I wanted to do a simple inner join between two tables in my DataSet. I resorted to sinking ItemDataBound and dynamically changing the Text property of the Cell after manually looking up the value I needed from the related table. Not exaclty elegant, but it worked.

Comments have been disabled for this content.