Call us! 512-349-0334 or (877) INDUSOFT

Read from and Write to Databases, Grids, and .CSV Files in InduSoft Web Studio

Customers occasionally contact us about how to read from and write to databases, grids, and .csv files.  This is a small application that demonstrates the functionality of reading and writing from/to each of these objects.

As you read, feel free to download and explore the InduSoft Web Studio application here.

There is an Access database in the project that has been populated with information from the Microsoft Northwind “customers” database which is used as the main data source.  This app (distributed as a v7.0 app, so users of v7.0 and v7.1 can access it) will write to a .csv file, which will populate the grid on the 2nd screen.  Selecting a row on the grid will stuff an array tag with values from each of the columns.  Here is the sequence of how it operates (All the functionality is in the buttons and objects—there are no scripts):

  1. Selecting a date and pushing the “Query” button will query the database (an access database in the project folder that was populated from SQL Server Northwind “Orders”) and puts a/some selected row(s) into the first grid.
  2. The first row is selected by default, and if multiple records were returned (try later dates to get multiple rows), select a desired row, then push the “Load Selected” button, which loads the selected row into the lower grid.
  3. Pushing the “Save Concatenated String to .csv” button creates a concatenated string and saves it to the file name shown in the field.  The default .csv file is “Test1.csv” and you can create any other name by selecting the “Name” field and writing the new filename.extension in the field.
  4. Next, go to the .csv screen and see that the same filename.extension is in the field at the top.  Changing it and/or pushing enter will reload the grid with the file listed in the file field.  You can change this as necessary.  You sort the entire grid by selecting any Column Name: it toggles from A to Z then to Z to A.  If you want to reload as it comes from the .csv file, simply push the “Reload Grid” Button.
  5. Finally, selecting any row on the grid will populate the cells containing an array tag at the bottom showing how to get the .csv info back into tags.

InduSoft Web Studio SCADA Software Application

InduSoft Web Studio SCADA Software Application

Leave a Reply