Connect to Cvent Data from Blazor Apps



Build ASP.NET Core Blazor C# apps that integrate with real-time Cvent data using standard SQL.

Blazor is a framework for developing modern, client-side web UIs using .NET technology. Instead of coding in JavaScript, developers can use the familiar C# language and .NET libraries to build app UIs.

The CData ADO.NET Provider for Cvent can be used with standard ADO.NET interfaces, such as LINQ and Entity Framework, to interact with live Cvent data. Since Blazor supports .NET Core, developers can use CData ADO.NET Providers in Blazor apps. In this article, we will guide you to build a simple Blazor app that talks to Cvent using standard SQL queries.

Install the CData ADO.NET Provider for Cvent

CData ADO.NET Providers allow users to access Cvent just like they would access SQL Server, using simple SQL queries.

Install the Cvent ADO.NET Data Provider from the CData website or from NuGet. Search NuGet for "Cvent ADO.NET Data Provider."

Create a Cvent-Connected Blazor App

Start by creating a Blazor project that references the CData ADO.NET Provider for Cvent

  1. Create a Blazor project on Visual Studio.
  2. From the Solution Explorer, right click Dependencies, then click Add Project Reference.
  3. In the Reference Manager, click the Browse button, and choose the .dll file of the installed ADO.NET Provider (e.g. System.Data.CData.Cvent.dll, typically located at C:\Program Files\CData\CData ADO.NET Provider for Cvent\lib etstandard2.0).

SELECT Cvent Data from the Blazor App

  1. Open the Index.razor file from the Project page.
  2. In a CventConnection object, set the connection string:

    Before you can authenticate to Cvent, you must create a workspace and an OAuth application.

    Creating a Workspace

    To create a workspace:

    1. Sign into Cvent and navigate to App Switcher (the blue button in the upper right corner of the page) >> Admin.
    2. In the Admin menu, navigate to Integrations >> REST API.
    3. A new tab launches for Developer Management. Click on Manage API Access in the new tab.
    4. Create a Workspace and name it. Select the scopes you would like your developers to have access to. Scopes control what data domains the developer can access.
      • Choose All to allow developers to choose any scope, and any future scopes added to the REST API.
      • Choose Custom to limit the scopes developers can choose for their OAuth apps to selected scopes. To access all tables exposed by the driver, you need to set the following scopes:
        event/attendees:readevent/attendees:writeevent/contacts:read
        event/contacts:writeevent/custom-fields:readevent/custom-fields:write
        event/events:readevent/events:writeevent/sessions:delete
        event/sessions:readevent/sessions:writeevent/speakers:delete
        event/speakers:readevent/speakers:writebudget/budget-items:read
        budget/budget-items:writeexhibitor/exhibitors:readexhibitor/exhibitors:write
        survey/surveys:readsurvey/surveys:write

    Creating an OAuth Application

    After you have set up a Workspace and invited them, developers can sign up and create a custom OAuth app. See the Creating a Custom OAuth Application section in the Help documentation for more information.

    Connecting to Cvent

    After creating an OAuth application, set the following connection properties to connect to Cvent:

    • InitiateOAuth: GETANDREFRESH. Used to automatically get and refresh the OAuthAccessToken.
    • OAuthClientId: The Client ID associated with the OAuth application. You can find this on the Applications page in the Cvent Developer Portal.
    • OAuthClientSecret: The Client secret associated with the OAuth application. You can find this on the Applications page in the Cvent Developer Portal.

    For example: OAuthClientId=MyOAuthClientId;OAuthClientSecret=MyOAuthClientSecret;

  3. The code below creates a simple Blazor app for displaying Cvent data, using standard SQL to query Cvent just like SQL Server.

          @page "/"
          @using System.Data;
          @using System.Data.CData.Cvent;
          
          <h1>Hello, world!</h1>
          
          Welcome to your Data app.
          
          <div class="row">
              <div class="col-12">
          
                  @using (CventConnection connection = new CventConnection(
                    "OAuthClientId=MyOAuthClientId;OAuthClientSecret=MyOAuthClientSecret;"))
                  {
                      var sql = "SELECT Id, Title FROM Events WHERE Virtual = 'true'";
                      var results = new DataTable();
          
                      CventDataAdapter dataAdapter = new CventDataAdapter(sql, connection);
                      dataAdapter.Fill(results);
          
                      <table class="table table-bordered">
                          <thead class="thead-light">
                              <tr>
                                  @foreach (DataColumn item in results.Rows[0].Table.Columns)
                                  {
                                      <th scope="col">@item.ColumnName</th>
                                  }
                              </tr>
                          </thead>
                          <tbody>
                              @foreach (DataRow row in results.Rows)
                              {
                                  <tr>
                                      @foreach (var column in row.ItemArray)
                                      {
                                          <td>@column.ToString()</td>
                                      }
                                  </tr>
                              }
                          </tbody>
                      </table>
                  }
              </div>
          </div>
        
  4. Rebuild and run the project. The ADO.NET Provider renders Cvent data as an HTML table in the Blazor app.

    At this point, you have a Cvent-connected Blazor app, capable of working with live Cvent data just like you would work with a SQL Server instance. Download a free, 30-day trial and start working with live Cvent data in your Blazor apps today.

Ready to get started?

Download a free trial of the Cvent Data Provider to get started:

 Download Now

Learn more:

Cvent Icon Cvent ADO.NET Provider

Rapidly create and deploy powerful .NET applications that integrate with Cvent.