Ready to get started?

Learn more about the CData ADO.NET Provider for CSV or download a free trial:

Download Now

Connect to CSV Data from LightSwitch Desktop Applications

Create LightSwitch applications with connectivity to CSV data.

The CData ADO.NET Provider for CSV enables you to integrate CSV data into LightSwitch applications. You can follow this procedure to create a simple LightSwitch Desktop application that displays CSV data in a screen.

Connect from Your Project and Import Tables

Follow the steps below to configure connection properties and import tables in the Data Source Configuration wizard.

  1. In a new LightSwitch Project, click 'Attach to external Data Source'.
  2. In the wizard that appears, select Database. The Add Connection dialog is displayed.
  3. Click Change to select the CData CSV Data Source.
  4. Enter the connection properties.

    The DataSource property must be set to a valid local folder name. Also, specify the IncludeFiles property to work with text files having extensions that differ from .csv, .tab, or .txt. Specify multiple file extensions in a comma-separated list. You can also set Extended Properties compatible with the Microsoft Jet OLE DB 4.0 driver. Alternatively, you can provide the format of text files in a Schema.ini file.

    Below is a typical connection string:

    DataSource=MyCSVFilesFolder;

    Additionally, set the CacheLocation and CacheMetadata properties to improve performance. The performance benefits gained from caching metadata are especially relevant in LightSwitch projects, as creating the entity model requires data about every table and column. Cache the metadata before connecting to CSV so that LightSwitch can pull the table schemas from the cache instead of sending a query for every table.

    See the "Caching Data" chapter in the help documentation for more information on the provider's caching features.

  5. Select the tables you would like to add to the project. For example, Customer.

Add a Screen

Follow the steps below to associate a screen with a CSV table. This example uses an editable grid, which will enable you to insert and update CSV data.

  1. In Solution Explorer, right-click the Screens folder and then click Add Screen.
  2. In the resulting wizard, select the Editable Grid screen template.
  3. In the Screen Data menu, select which table or view to associate with the screen. For example, Customer.
  4. Run the LightSwitch application. The screen will automatically execute and populate with data.
 
 
Downloads