I have a Visual Basic application with a very complex search page, most of which works exactly as planned. One piece of the SELECT statement, simplified for testing, reads thus:
[SELECT #1]
SELECT STRUC_ID, DRWG_NO, STRUC_NM, STRUC_TYP_CD
FROM dbo_STRUC
WHERE (dbo_STRUC.STRUC_ID IN (SELECT STRUC_ID FROM
dbo_STRUC_WRK WHERE dbo_STRUC_WRK.STRUC_WRK_NO IN
(SELECT STRUC_WRK_NO FROM dbo_STRUC_WRK_CALCBOOK
WHERE dbo_STRUC_WRK_CALCBOOK.CALCBOOK_NO
[This piece looks for "Structures" sharing a given "CalcBook".]
I have another source of Structure/CalcBook relations, so to broaden the search I want to add this piece (again, formulated for testing):
[SELECT #2]
SELECT STRUC_ID, DRWG_NO, STRUC_NM, STRUC_TYP_CD
FROM dbo_STRUC
WHERE (dbo_STRUC.STRUC_ID IN (SELECT StructureNo FROM
Structures WHERE Structures.CalcBook=?))
I have tested each piece separately, and have gotten the list of Structures that share the input CalcBook. However, when I combine SELECT statements #1 and #2, the SELECT statement bombs with an "attempt to read protected memory" error 0xc0000005, whether in MS ACCESS [which crashes completely] or in VB 2005 (ADO code or DataSet Designer) [VB traps the error], and whether I use a parameter for the '?' or a hard-coded value.
The blended filter piece looks like this:
[SELECT#3]
SELECT STRUC_ID, DRWG_NO, STRUC_NM, STRUC_TYP_CD
FROM dbo_STRUC
WHERE ((dbo_STRUC.STRUC_ID IN (SELECT STRUC_ID FROM
dbo_STRUC_WRK WHERE dbo_STRUC_WRK.STRUC_WRK_NO IN
(SELECT STRUC_WRK_NO FROM dbo_STRUC_WRK_CALCBOOK
WHERE dbo_STRUC_WRK_CALCBOOK.CALCBOOK_NO=?))) OR
(dbo_STRUC.STRUC_ID IN (SELECT StructureNo FROM
Structures WHERE Structures.CalcBook = ?)))
I've counted parentheses a hundred times, and have just about scratched my head bald over this one. I'm sure it must be a simple DUH!, but haven't got a clue (I did recently get new glasses...). Does anything obvious pop out?
[SELECT #1]
SELECT STRUC_ID, DRWG_NO, STRUC_NM, STRUC_TYP_CD
FROM dbo_STRUC
WHERE (dbo_STRUC.STRUC_ID IN (SELECT STRUC_ID FROM
dbo_STRUC_WRK WHERE dbo_STRUC_WRK.STRUC_WRK_NO IN
(SELECT STRUC_WRK_NO FROM dbo_STRUC_WRK_CALCBOOK
WHERE dbo_STRUC_WRK_CALCBOOK.CALCBOOK_NO
[This piece looks for "Structures" sharing a given "CalcBook".]
I have another source of Structure/CalcBook relations, so to broaden the search I want to add this piece (again, formulated for testing):
[SELECT #2]
SELECT STRUC_ID, DRWG_NO, STRUC_NM, STRUC_TYP_CD
FROM dbo_STRUC
WHERE (dbo_STRUC.STRUC_ID IN (SELECT StructureNo FROM
Structures WHERE Structures.CalcBook=?))
I have tested each piece separately, and have gotten the list of Structures that share the input CalcBook. However, when I combine SELECT statements #1 and #2, the SELECT statement bombs with an "attempt to read protected memory" error 0xc0000005, whether in MS ACCESS [which crashes completely] or in VB 2005 (ADO code or DataSet Designer) [VB traps the error], and whether I use a parameter for the '?' or a hard-coded value.
The blended filter piece looks like this:
[SELECT#3]
SELECT STRUC_ID, DRWG_NO, STRUC_NM, STRUC_TYP_CD
FROM dbo_STRUC
WHERE ((dbo_STRUC.STRUC_ID IN (SELECT STRUC_ID FROM
dbo_STRUC_WRK WHERE dbo_STRUC_WRK.STRUC_WRK_NO IN
(SELECT STRUC_WRK_NO FROM dbo_STRUC_WRK_CALCBOOK
WHERE dbo_STRUC_WRK_CALCBOOK.CALCBOOK_NO=?))) OR
(dbo_STRUC.STRUC_ID IN (SELECT StructureNo FROM
Structures WHERE Structures.CalcBook = ?)))
I've counted parentheses a hundred times, and have just about scratched my head bald over this one. I'm sure it must be a simple DUH!, but haven't got a clue (I did recently get new glasses...). Does anything obvious pop out?