Skip to main content
Home  › ... Razor

External Data from CSV or SQL

Tutorial HomeExternal Data

Various SQL Samples

The samples can differ based on your Razor base class or if you're running an old version.
Switch to Typed (2sxc 16+) Switch to Dynamic (Razor14 or below)

SQL from an App Query

The easiest way to get SQL data is using Visual Query. Note that this only works, if your razor is inside 2sxc/eav. This example gets the list of files from DNN using a query like
Select Top 10 * from Files Where PortalId = [Params:SiteId]
Note that the parameter SiteId is preset to be [Site:Id].

Requirements

SQL from a App Query, setting Params

The easiest way to get SQL data is using Visual Query. Note that this only works, if your razor is inside 2sxc/eav. This example gets the list of files from DNN using a query like
Select Top 10 * from Files Where SiteId = [Params:SiteId]
Here we override the parameter SiteId=1.

Run an App Query multiple times on the same page

The previous examples showed how to use a Query. Now we want to run the query twice, which requires a Reset().
Note that the parameter SiteId is preset to be [Site:Id].

SQL Datareader