[Webinar] Streamline your web hosting managementRegister Today

  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 373
  • Last Modified:

sorting on merged datasets

I have merged two datasets but now need to sort on the dtmappt so that the dates display correctly.  How can I sort on a merged dataset please?

MyCommand = New SqlDataAdapter("SELECT  a.APPTDATE as apptdate, a.APPTREASON AS apptreason  FROM tblPSPatient s INNER JOIN HealthDistrict.dbo.DDB_PAT_BASE p ON s.lngPatientid = p.CHART INNER JOIN HealthDistrict.dbo.DDB_APPT_BASE a ON p.PATID = a.PATID  where lngPSPatientid = '" & patid & "'and a.apptdate > '" & brokendate & "'  ORDER BY s.lngPSPatientid, a.APPTDATE", Connection1)
            DS1 = New DataSet
            MyCommand.Fill(DS1, "MyTable")
            MyCommand = New SqlDataAdapter("SELECT d.dtmScreening as apptdate,   'Project Smile Screening' AS apptreason FROM HealthDistrict.dbo.tblDentalScreening d INNER JOIN HealthDistrict.dbo.tblPatient p ON d.lngPatientid = p.lngPatientId LEFT OUTER JOIN tblPSPatient pat ON p.strLName = pat.strlname AND p.strFName = pat.strfname AND p.strPatientId = pat.lngPatientid  where lngPSPatientid = '" & patid & "' ", Connection1)
            DS2 = New DataSet
            MyCommand.Fill(DS2, "MyTable")

Open in new window

  • 2
  • 2
1 Solution
if you are using 2005 you can do following

DataView dv = new DataView(ds1.Tables[0]);
string order = "dtmappt ASC";
dv.Sort = order;

dv.totable(<Nerw Table you want to copy sorted data to>)

running32Author Commented:
I am using 2003.net  visual basic.  Thanks
Then you have to loop through the data view and insert each row in to new dataset.
running32Author Commented:
I was able to modify.  Thanks so much

 Dim dv1 As New DataView(DS1.Tables(0))
            dv1.Sort = "apptdate desc"

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now