Link to home
Start Free TrialLog in
Avatar of running32
running32

asked on

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?

thanks
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")
 
 
            ds1.merge(ds2)

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of vs1784
vs1784

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of running32
running32

ASKER

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.
I was able to modify.  Thanks so much

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