Free DNN Module: Advanced DataGrid (Part 1)

Location: BlogsAll BlogsDNN Development    
Posted by: mamlin 2/27/2008 5:05 PM

The "Advanced DataGrid" module by Efficion Consulting has been around for years.  It allows you to make direct SQL queries into the DNN database and return the results in a basic HTML table.  This is by no means the only module to offer such functionality but the Advanced Datagrid module (and source code) are FREE.  The module is no longer being actively developed but it continues to be useful to those seeking to extend DNN functionality without spending money.

Download
The module and source code continue to be offered as free downloads from Efficion:
http://www.efficionconsulting.com/tabid/217/Default.aspx

The latest version is 3.1.3.  It was developed for DNN 3.x but we use it in production on DNN 4.6.2.  (I have not yet tested it on DNN versions above 4.6.2.)

Examples
I'll cover one example in this "Part 1" post and I'll follow up with a second example in a "Part 2" post.  For "Part 1", let's use the ADG module to create a list showing the ten most recent signups on our DNN portal.  This list will include the user ID, date of account creation, username, firstname, lastname, displayname, email and registration status.  NOTE:  Since this list will contain user names and emails, you'll probably want to configure the module to be viewed by administrators only.

Once you've got the ADG module installed and added to a test page, open the module Settings.  Under the "Advanced DataGrid Settings" section, add (copy-pand-paste) the following SQL statement:

SELECT DISTINCT TOP (10)
  u.UserID, aspm.CreateDate, u.Username, u.DisplayName, 
  u.FirstName, u.LastName, u.Email, up.Authorised
FROM 
  UserRoles AS ur INNER JOIN
  Users AS u ON u.UserID = ur.UserID INNER JOIN
  Roles AS r ON r.RoleID = ur.RoleID INNER JOIN
  aspnet_Users AS aspu ON aspu.UserName = u.Username INNER JOIN
  aspnet_Membership AS aspm ON aspm.UserId = aspu.UserId INNER JOIN
  UserPortals AS up ON up.UserId = u.UserID
WHERE (r.PortalID = [dnn:PortalID])
ORDER BY u.UserID DESC

Now click "Update" and you're done.  You should now have a very basic table with the expected "most recent user signups" information.

Suggestions
Now that you've got a working list, you can extend its usefulness with different data.  How about a query that returns a list of users with matching email addresses (to help identify users with multiple accounts).  Or maybe a list of users based on the most recent log in date?  Or the top ten users with the largest number of failed login attempts?

Calling Stored Procedures
The most  notable restriction is the size of the query you can execute -- white space and carriage returns count so use then sparringly on longer queries.  Unfortunately you won't know that your query is too long until you've saved it and then gone back into Settings to see that it has been truncated.  If your query is THAT big you should probably be seriously thinking about converting it to a stored procedure anyway.

To call a stored procedure with the ADG module simply use the "exec" command.  For example, to execute the DNN stored procedure "GetDatabaseVersion" you would use:

  exec GetDatabaseVersion


That's it for this introduction to the Advanced DataGrid module.  Cheers to Efficion for continuing to make the module and source code available.  In "Part 2" we'll look at a simple example using ADG to create a "dashboard" report for the DNN Events calendar.
 
Part 2 is now available here:  http://www.eguanasolutions.com/DNN_Blog/EntryID/5.aspx
 

Permalink |  Trackback

Comments (6)   Add Comment
Re: Free DNN Module: Advanced DataGrid (Part 1)    By Asif Qayyum on 1/27/2009 9:38 AM
Hi, We have been searching for something good as this post is. Thanks for solving an issue, which was causing a lot of troubles. We will surely be looking for your future posts. Once again, Great Post!! Regards, Asif Qayyum (Web Admin) Wisdom IT Solutions LLC www.wistech.biz

Re: Free DNN Module: Advanced DataGrid (Part 1)    By David O'Leary on 8/6/2009 5:40 AM
Thanks for the writeup. Someday, we will get back to active development on this module. We've built out lots of features for clients and projects, but we haven't had the time to wrap them all together and package them up for release... -David O'Leary, Efficion Consulting

Re: Free DNN Module: Advanced DataGrid (Part 1)    By Richard on 8/22/2009 9:26 PM
Can Sql statement use a parameter from QueryString?

Re: Free DNN Module: Advanced DataGrid (Part 1)    By mamlin on 8/22/2009 9:29 PM
Hi, Richard- The ADG module does not support querystrings but the more advanced (and also free) SQLView module does support querystring values as part of the SQL statement. See my posting on the free SQLView module here: http://www.eguanasolutions.com/DNN_Blog/EntryID/15.aspx

Re: Free DNN Module: Advanced DataGrid (Part 1)    By John Kadwell on 8/31/2009 11:47 AM
error: System.Data.OleDb.OleDbException: Line 1: Incorrect syntax near '('. at Microsoft.VisualBasic.CompilerServices.LateBinding.LateGet(Object o, Type objType, String name, Object[] args, String[] paramnames, Boolean[] CopyBack) _____ I get the above error when running the query. Any idea what is going wrong?

Re: Free DNN Module: Advanced DataGrid (Part 1)    By mamlin on 8/31/2009 11:54 AM
John- I've sometimes seen issues when enabling the column sort option in ADG -- do you have this option enabled? The core REPORTS module has eclipsed ADG in features...these days I recommend using it or the free SQLView module in place of ADG (though I continue to use ADG on a number of older sites). You can use the same query shown in the example -- you'll just need to replace the [dnn:PortalID] token shown above for the appropriate portal ID token under REPORTS or SQLView which each have their own token variations.


Your name:
Title:
Comment:
Security Code
Enter the code shown above in the box below
Add Comment   Cancel 
You are here:  
 
>> Back to the top of the blog list...

 
        account   advanced   blog   click   cloud   code   content   create   data   different   events   example   feature   file   files   free   function   good   google   just   line   list   module   modules   need   option   page   pages   query   results   role   roles   script   search   select   settings   simple   site   skin   solution   step   tags   terms   time   user   users   value   version   want  
Minimize Google AJAX Search
 
Search ES:  
This is an example of a Google AJAX Search with asynchronous search execution for two searches.  See our blog series, 'Add Google AJAX Search to your DNN skin' for info and sample code.
 
     
Minimize Get the T-Shirt
 
Shirts by Eguana Solutions
(Be cool like us!)
 
     
Minimize Most-Commented Blogs
 
 
     

Minimize Looking for more info?
 

There are tons of helpful
posts from Eguana Solutions 
on the DotNetNuke.com forums.
  
 
Click HERE to see our posts.

 
     
Minimize Modules for Sale
 

Looking for Eguana's modules? 
We're still working on them!
  

Until ours are ready to dazzle and
amaze, you'll have to make do with
the thousands of modules already
available on SnowCovered.

 
     
Minimize Favorite Modules
 

There are many great DNN modules.
A few we highly recommend are:
 
Dynamic Registration
Total control over the user signup process.  Create custom forms, execute your own SQL, use the integrated payment processing features to assign user roles, validate USERNAMEs via AJAX and much more.  Very cool.
 
URL Master
Change to friendly URLs that really ARE friendly.  Add keywords into your page URLs for better SEO.  Create 301 redirects for individual pages.  Force visitors (and search bots) to a single domain (i.e., make everyone use the "www" version of your site's URL or vice versa).  One of the single best upgrades for any DNN site.
 
Document Exchange 5 (DMX5)
Drag-and-drop from Windows Explorer directly into the DMX file manager!  File versioning, file and folder moderation, extend user permissions down to the file level (for user groups and even for individual users).  Infinite file and file info presentation options via custom display templates.  Store files locally or remotely via UNC (i.e., can securely store files somewhere besides your web server).  Much more.
 
XMOD by DNNDev
Rock-solid form module for data collection.  From simple feedback / email forms to complex, multi-part tabbed forms.  XMOD is different from other form modules because XMOD does not create a new database table for every new form definition -- an important feature if you plan to create dozens or hundreds of forms over the life of your DNN instance!  Excellent support from the developer and an active community around this module.
 
If you desire your form module to create a new DB table for each new form definition, a great alternative to XMOD is the Dynamic Forms module from DataSprings.  Dynamic Forms offers direct DB access beyond that found in XMOD as well as an easy drag-and-drop form builder option to help you get up and running very quickly.

 
     

Login