Logo
Logo
  • Blazor CMS Home
  • Oqtane Tutorials
  • Blazor CMS Home
  • Oqtane Tutorials
Oqtane Tutorials
Oqtane Tutorials

External Data from CSV or SQL

Tutorial Home › External Data
Example from CSV
#2 Various SQL Samples
Use DNN APIs to get DNN 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)
Requirements
  • 2sxc 06.05
Resources
  • App Query
  • DnnSqlDataSource Docs

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
  • 2sxc 12.08
Resources
  • App Query
  • Query Params

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.

Requirements
  • 2sxc 06.05
Resources
  • App Query
  • DnnSqlDataSource Docs

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].

Requirements
  • 2sxc 12.08
Resources
  • ConfigurationManager
  • More intro-material for direct database access
  • SqlCommand
  • SQLConnection
  • DnnSqlDataSource Docs

SQL Database

SQL Datareader

 

 

Example from CSV
#2 Various SQL Samples
Use DNN APIs to get DNN Data
  • 2sic internet solutions
  • Langäulistrasse 62, 9470 Buchs SG, Switzerland
  • +41 81 750 67 77
Login