Products

Solutions

Resources

Partners

Community

Blog

About

QA

Ideas Test

New Community Website

Ordinarily, you'd be at the right spot, but we've recently launched a brand new community website... For the community, by the community.

Yay... Take Me to the Community!

Welcome to the DNN Community Forums, your preferred source of online community support for all things related to DNN.
In order to participate you must be a registered DNNizen

HomeHomeDNN Open Source...DNN Open Source...Module ForumsModule ForumsForm and ListForm and Listsql query /stored proc to get data from udt in another web app non dnnsql query /stored proc to get data from udt in another web app non dnn
Previous
 
Next
New Post
2/11/2008 12:52 PM
 

I am having some trouble following. I want to get UDT data into the SQLGridSelectedView module. That module has both an SQL window and an SQL connection string line.

I have a UDT named "Add Machines" with fields Brand (text 50), Model (T50) and Painting (checkbox). How would I structure the SQL for the SQLGridSelectedView Module? (or just one section if each section is similar for the other text fields). Do I also need to use the SQL connection string line (with the SQL call itself)?

thanks.

-fiz

 
New Post
2/11/2008 12:54 PM
 

Sorry, AFAIK SQLGridSelectedView does not have a dataprovider for UDT. I suggest to have a look at core Reports module instead, latest version comes with a built in UDT provider.


Cheers from Germany,
Sebastian Leupold

dnnWerk - The DotNetNuke Experts   German Spoken DotNetNuke User Group

Speed up your DNN Websites with TurboDNN
 
New Post
2/11/2008 8:16 PM
 

Well... I have been thinking about this for a while...  how best to support UDT in SQLGridSelectedView.  My current belief is I shouldn't as I can't know all the possible needs. 

So I decided to develop a generic Stored Procedure that can be tailored for most users if it is not correct out of the box.   Try the following procedure and see if that will do the trick.   You can install the procedure via the Host>SQL page.

IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[GetUserDefinedDatabyModule]') AND type in (N'P', N'PC'))
    DROP PROCEDURE [dbo].[GetUserDefinedDatabyModule]
go

Create Procedure [dbo].[GetUserDefinedDatabyModule]
  @ModuleID int,
  @VisibleOnly bit = 0
as

-- exec GetUserDefinedDatabyModule 440         -- default - show all
-- exec GetUserDefinedDatabyModule 440, 0    -- show all
-- exec GetUserDefinedDatabyModule 440, 1    -- show visible only

declare @FieldTitle varchar(50)
declare @FieldType varchar(20)
declare @FieldVisible bit
declare @CastTo varchar(100)
declare @crlf as char(2)
declare @SqlCmd varchar(8000)

Set @Crlf = char(13) + char(10)
Set @SqlCmd = 'Select ModuleID, UserDefinedRowId ' + @crlf

declare UDRFields Cursor 
for select FieldTitle, FieldType, Visible 
    from  dbo.UserDefinedFields 
    where ModuleID = @ModuleID
    Order by FieldOrder

open UDRFields
fetch next from UDRFields into @FieldTitle, @FieldType, @FieldVisible

while (@@fetch_status <> -1)
  begin
    if @FieldVisible >= @VisibleOnly
      begin

        set @CastTo = (
            Case @FieldType
            when 'String'    then 'Cast(UDD.[FieldValue] as varchar(100))'
            when 'Boolean'   then 'Cast(UDD.[FieldValue] as varchar(5))'
            when 'Int32'     then 'Cast(UDD.[FieldValue] as varchar(10))'
            when 'Currency'  then 'CAST(Cast(UDD.[FieldValue] as varchar(20)) AS decimal(17,2))'
            when 'Date'      then 'CAST(Cast(UDD.[FieldValue] as varchar(20)) AS datetime)'
            when 'CreatedBy' then 'Cast(UDD.[FieldValue] as varchar(50))'
            when 'CreatedAt' then 'CAST(Cast(UDD.[FieldValue] as varchar(20)) AS datetime)'
            when 'ChangedBy' then 'Cast(UDD.[FieldValue] as varchar(50))'
            when 'ChangedAt' then 'CAST(Cast(UDD.[FieldValue] as varchar(20)) AS datetime)'
                             else 'Cast(UDD.[FieldValue] as varchar(50))'
            end)

        Set @SqlCmd = @SqlCmd + ',(SELECT TOP 1 ' + @CastTo + ' ' + @crlf
        Set @SqlCmd = @SqlCmd + ' FROM UserDefinedData UDD with (nolock), userdefinedfields UDF with (nolock)' + @crlf
        Set @SqlCmd = @SqlCmd + ' WHERE UDD.[UserDefinedRowId]   = udr.[UserDefinedRowId]' + @crlf
        Set @SqlCmd = @SqlCmd + ' AND UDD.[UserDefinedFieldId] = udf.[UserDefinedFieldId]' + @crlf
        Set @SqlCmd = @SqlCmd + ' AND UDF.[ModuleId] = udr.[ModuleId]' + @crlf
        Set @SqlCmd = @SqlCmd + ' AND UDF.[FieldTitle] = ''' + @FieldTitle + ''''
        Set @SqlCmd = @SqlCmd + ') AS [' + @FieldTitle + '] ' + @crlf
      end
    fetch next from UDRFields into @FieldTitle, @FieldType, @FieldVisible
  end

close UDRFields
deallocate UDRFields

Set @SqlCmd = @SqlCmd + 'FROM [userdefinedrows] UDR with (nolock) ' + @crlf
Set @SqlCmd = @SqlCmd + 'WHERE  UDR.[moduleid] = ' + Cast(@ModuleID as varchar) + @crlf
Set @SqlCmd = @SqlCmd + 'ORDER BY udr.UserDefinedRowID' +@crlf

--Print len(@sqlcmd)
--Print @SqlCmd

Exec( @SQLcmd)

Return @@rowcount

 

Several limitation exist - the biggest is the 8000 character limit on the generated Select, however 10 to 15 field should be OK.  Also the performance will be rather slow on large volume of data.  I would suggest special handling in those cases.   Also, I have limited the text (string) field to 100 characters -- this may need to be altered based on what you are trying to display.

I believe it's good start.  Hope it helps.
Paul.

 
New Post
2/13/2008 3:56 PM
 

Sebastian Leupold wrote

...I suggest to have a look at core Reports module instead, latest version comes with a built in UDT provider.

I would be interested (and I'm sure many others) if you can post a step by step of how to use the Reports module with UDT provider.

Thank you.

 
Previous
 
Next
HomeHomeDNN Open Source...DNN Open Source...Module ForumsModule ForumsForm and ListForm and Listsql query /stored proc to get data from udt in another web app non dnnsql query /stored proc to get data from udt in another web app non dnn


These Forums are dedicated to discussion of DNN Platform and Evoq Solutions.

For the benefit of the community and to protect the integrity of the ecosystem, please observe the following posting guidelines:

  1. No Advertising. This includes promotion of commercial and non-commercial products or services which are not directly related to DNN.
  2. No vendor trolling / poaching. If someone posts about a vendor issue, allow the vendor or other customers to respond. Any post that looks like trolling / poaching will be removed.
  3. Discussion or promotion of DNN Platform product releases under a different brand name are strictly prohibited.
  4. No Flaming or Trolling.
  5. No Profanity, Racism, or Prejudice.
  6. Site Moderators have the final word on approving / removing a thread or post or comment.
  7. English language posting only, please.
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out