% 'First check if the database has the Selectable attribute in the references to only select those references. '-------------------------------------------------------------------------------------------------------------------------- SQL="SELECT sysobjects.name AS Exp1 FROM sysobjects INNER JOIN syscolumns ON sysobjects.id = syscolumns.id WHERE (sysobjects.name LIKE 'Reference') AND (syscolumns.name LIKE N'Selectable')" Set RVisibleCol = Server.CreateObject("ADODB.Recordset") RVisibleCol.ActiveConnection = MM_jun_STRING RVisibleCol.Source = SQL RVisibleCol.CursorType = 3 RVisibleCol.CursorLocation = 2 RVisibleCol.LockType = 1 RVisibleCol.Open() if RVisibleCol.RecordCount > 0 then SelectableColExist= True else SelectableColExist= False end if RVisibleCol.close set RVisibleCol=Nothing 'I create a different SQL depending if the Visible column exist or not in the database if SelectableColExist= True then SQL="SELECT RefCache, RefId FROM Reference WHERE (Selectable = 1)" Else SQL="SELECT DISTINCT Reference.RefCache, dbo.Reference.RefId FROM Reference INNER JOIN PTaxon ON dbo.Reference.RefId = PTaxon.PTRefFk" End if '-------------------------------------------------------------------------------------------------------------------------- 'Select all the available sources to present into the Reference box Set Rsources = Server.CreateObject("ADODB.Recordset") Rsources.ActiveConnection = MM_jun_STRING Rsources.Source = SQL Rsources.CursorType = 3 Rsources.CursorLocation = 2 Rsources.LockType = 1 Rsources.Open() %>
Search! | |
|