Critical error when running sql qry
Last Post 04-15-2010 12:35 PM by Curtis Eidson. 8 Replies.
AddThis - Bookmarking and Sharing Button
Author Messages
Curtis EidsonUser is Offline
river guide
river guide
Posts:98
Avatar

--
04-14-2010 10:00 AM

    Hi-

    Just downloaded the trial and ready to buy this module....however,...it doesn't seem to work for me.  I tested my sql qry via the host/sql module and my sql works. I receive an error when I click "export to excel":

    A critical error has occurred.
    Incorrect syntax near the keyword 'declare'. Incorrect syntax near ')'.

    here is my sql query:

    declare @EventID int
    select @EventID = EventID FROM companytable_Event where substring(EventName,1,3) = 'ANA' and IsCurrent = 'True'

    select
        ContractorName,
        isnull(dbo.fn_GetProfilePropertyValue(u.UserID,'CompanyName'),'') as CompanyName,
        (ISNULL(CAST(ab.BoothID1 As varchar(100)) ,'') + ISNULL(',' + CAST(ab.BoothID2 As varchar(100)),'') + ISNULL(','+ CAST(ab.BoothID3 As varchar(100)) ,'') + ISNULL(',' + CAST(ab.BoothID4 As varchar(100)) ,'')) As [Booth Numbers(s)]
    from
        Users u INNER JOIN companytable_IndependentContractorForm ic ON u.UserID = ic.ExhibitorID INNER JOIN companytable_EventForm ef ON ef.RecordID = ic.ContractorID AND ef.FormName = 'Independent Contractor Request Form' and ef.EventID = @EventID
        LEFT JOIN (companytable_AssignBooth ab INNER JOIN companytable_EventForm ef1 ON ab.AssignID = ef1.RecordID AND ef1.FormName = 'Assign Booths' AND ef1.EventID = @EventID) ON ab.ExhibitorID = u.UserID
         and u.UserID > 2
    order by   
        CompanyName

    David ToUser is Offline
    river guide
    river guide
    Posts:2719
    Avatar

    --
    04-14-2010 10:44 AM
    Hi, I notice that you have two "select" statements. Can you modify it to:

    set @EventID = ( select EventID FROM companytable_Event where substring(EventName,1,3) = 'ANA' and IsCurrent = 'True')

    This way, you are only executing one select statement. -- David
    Curtis EidsonUser is Offline
    river guide
    river guide
    Posts:98
    Avatar

    --
    04-14-2010 11:51 AM
    Hi David-

    I'm not sure I understand. Running the first select statement doesn't give me the data that I need. I tried to run the sql as you have suggested and I get another sql error
    Incorrect syntax near the keyword 'set'. Must declare the scalar variable "@EventID".

    my sql statement runs fine using Host/sql and returns the results that I need.

    thanks.
    David ToUser is Offline
    river guide
    river guide
    Posts:2719
    Avatar

    --
    04-14-2010 11:59 AM
    HI, I meant change it to this:

    declare @EventID int
    set @EventID = ( select EventID FROM companytable_Event where substring(EventName,1,3) = 'ANA' and IsCurrent = 'True')
    select
    ContractorName,
    isnull(dbo.fn_GetProfilePropertyValue(u.UserID,'CompanyName'),'') as CompanyName,
    (ISNULL(CAST(ab.BoothID1 As varchar(100)) ,'') + ISNULL(',' + CAST(ab.BoothID2 As varchar(100)),'') + ISNULL(','+ CAST(ab.BoothID3 As varchar(100)) ,'') + ISNULL(',' + CAST(ab.BoothID4 As varchar(100)) ,'')) As [Booth Numbers(s)]
    from
    Users u INNER JOIN companytable_IndependentContractorForm ic ON u.UserID = ic.ExhibitorID INNER JOIN companytable_EventForm ef ON ef.RecordID = ic.ContractorID AND ef.FormName = 'Independent Contractor Request Form' and ef.EventID = @EventID
    LEFT JOIN (companytable_AssignBooth ab INNER JOIN companytable_EventForm ef1 ON ab.AssignID = ef1.RecordID AND ef1.FormName = 'Assign Booths' AND ef1.EventID = @EventID) ON ab.ExhibitorID = u.UserID
    and u.UserID > 2
    order by
    CompanyName

    -- David
    Curtis EidsonUser is Offline
    river guide
    river guide
    Posts:98
    Avatar

    --
    04-14-2010 12:16 PM

    Hi David-

    This looks like the same thing as my example with () around the first select & set replaced select? I've tried it and receive the same error:
    A critical error has occurred.
    Incorrect syntax near the keyword 'declare'. Incorrect syntax near ')'. 
     

    Curtis

    David ToUser is Offline
    river guide
    river guide
    Posts:2719
    Avatar

    --
    04-14-2010 01:14 PM
    Okay, how about removing the Declare and Set commands where you obtain the @EventID. Instead, just embed it all in one SQL select statement like this:

    select
    ContractorName,
    isnull(dbo.fn_GetProfilePropertyValue(u.UserID,'CompanyName'),'') as CompanyName,
    (ISNULL(CAST(ab.BoothID1 As varchar(100)) ,'') + ISNULL(',' + CAST(ab.BoothID2 As varchar(100)),'') + ISNULL(','+ CAST(ab.BoothID3 As varchar(100)) ,'') + ISNULL(',' + CAST(ab.BoothID4 As varchar(100)) ,'')) As [Booth Numbers(s)]
    from
    Users u INNER JOIN companytable_IndependentContractorForm ic ON u.UserID = ic.ExhibitorID INNER JOIN companytable_EventForm ef ON ef.RecordID = ic.ContractorID AND ef.FormName = 'Independent Contractor Request Form' and ef.EventID in (select EventID FROM companytable_Event where substring(EventName,1,3) = 'ANA' and IsCurrent = 'True')
    LEFT JOIN (companytable_AssignBooth ab INNER JOIN companytable_EventForm ef1 ON ab.AssignID = ef1.RecordID AND ef1.FormName = 'Assign Booths' AND ef1.EventID in (select EventID FROM companytable_Event where substring(EventName,1,3) = 'ANA' and IsCurrent = 'True')) ON ab.ExhibitorID = u.UserID
    and u.UserID > 2
    order by
    CompanyName

    -- David
    Curtis EidsonUser is Offline
    river guide
    river guide
    Posts:98
    Avatar

    --
    04-15-2010 09:09 AM
    Hi David-

    Thanks for the help. The worked great. I did have to remove the "order by" clause btw.

    Is this "issue" caused by a poorly constructed sql qry or could this actually be a bug that dynamic views does not support multiple sql select statements?

    thanks again!

    Curtis
    David ToUser is Offline
    river guide
    river guide
    Posts:2719
    Avatar

    --
    04-15-2010 12:25 PM
    Well, the problem for the moment with Dynamic Views, as far as I can tell, is that it only accepts one select statement to be returned and it does not accept stored procedures but we are always looking into improving for future enhancements. -- David
    Curtis EidsonUser is Offline
    river guide
    river guide
    Posts:98
    Avatar

    --
    04-15-2010 12:35 PM

    thanks again for you help with this.  I'm a long time user of datasprings dnn modules and (as always) you guys are great in every aspect!

     



    ---
  • film izle
  • 720 izle
  • film
  • sinema izle
  • film makinesi
  • T�rk�e dublaj film
  • film izle
  • film izle
  • baglan film izle
  • sinema izle
  • 1080 film izle
  • film mercegi