T
Tim Kelley
I am trying to populate a dataviewgrid with records from a database that are
duplicates. I have created 3 views to get the information I want, but if I
try to apply a filter to my bindingsource control, I am returned all
records, not just the duplicates. Here are my 3 SQL views:
View1: - records are dated by year, this view filters all except current
year
SELECT TOP 100 PERCENT fldCliID, fldName2, fldName1, fldAdd1, fldAdd2,
fldCity, fldState, fldZip, fldStudioNo, fldGraduationYear,
fldOrganizationID,
fldCliNo
FROM dbo.tblClients
WHERE (fldGraduationYear = N'2007')
ORDER BY fldName2, fldName1
View2: - this view actully picks out the dups only
SELECT TOP 100 PERCENT fldName2, fldName1, fldCliID, fldAdd1, fldAdd2,
fldCity, fldZip, fldCliNo, fldState, fldGraduationYear, fldOrganizationID
FROM dbo.VIEW1
WHERE (fldName2 IN
(SELECT [fldName2]
FROM [View1] AS Tmp
GROUP BY [fldName2], [fldName1]
HAVING COUNT(*) > 1 AND fldName1 =
dbo.View1.fldName1))
ORDER BY fldName2, fldName1
View3: - this is the view used in the program to pull the records into a
datatab;e
SELECT fldName2, fldName1, fldCliID, fldAdd1, fldAdd2, fldCity, fldZip,
fldCliNo, fldState, fldGraduationYear, fldOrganizationID
FROM dbo.VIEW2
After binding the datatable to the binding source and applying a filter (on
fldorganizationID), all records (for the selected organization) are
displayed.
Any ideas on a different way to accomplish this?
duplicates. I have created 3 views to get the information I want, but if I
try to apply a filter to my bindingsource control, I am returned all
records, not just the duplicates. Here are my 3 SQL views:
View1: - records are dated by year, this view filters all except current
year
SELECT TOP 100 PERCENT fldCliID, fldName2, fldName1, fldAdd1, fldAdd2,
fldCity, fldState, fldZip, fldStudioNo, fldGraduationYear,
fldOrganizationID,
fldCliNo
FROM dbo.tblClients
WHERE (fldGraduationYear = N'2007')
ORDER BY fldName2, fldName1
View2: - this view actully picks out the dups only
SELECT TOP 100 PERCENT fldName2, fldName1, fldCliID, fldAdd1, fldAdd2,
fldCity, fldZip, fldCliNo, fldState, fldGraduationYear, fldOrganizationID
FROM dbo.VIEW1
WHERE (fldName2 IN
(SELECT [fldName2]
FROM [View1] AS Tmp
GROUP BY [fldName2], [fldName1]
HAVING COUNT(*) > 1 AND fldName1 =
dbo.View1.fldName1))
ORDER BY fldName2, fldName1
View3: - this is the view used in the program to pull the records into a
datatab;e
SELECT fldName2, fldName1, fldCliID, fldAdd1, fldAdd2, fldCity, fldZip,
fldCliNo, fldState, fldGraduationYear, fldOrganizationID
FROM dbo.VIEW2
After binding the datatable to the binding source and applying a filter (on
fldorganizationID), all records (for the selected organization) are
displayed.
Any ideas on a different way to accomplish this?
