Lesson 4 - Data access

The data layer

The data layer gives us access to the data in the database and a way to retrieve and save data. Read about the structure of the data layer first.

Read through the following topics and explore the code in the development pack discovering how data is read from the database and how it is saved down.

Exercise

Task:

The task is to create a new table in the LS One database. Here is the script for the new table:


IF NOT EXISTS (SELECT * FROM INFORMATION_SCHEMA.TABLES where TABLE_NAME = 'FOO')
BEGIN
  CREATE TABLE FOO
  (
    BAR int,
    FIGHTERS uniqueIdentifier
  )
END

This is obviously not a very good table, with no primary key, no data area id and so on.

Follow the instructions in theHow to create/edit a database table topic to add this new data table.

Results:

When you have added the script, and run the Site Manager, you should see a brief flicker when the database update script is being applied.

In the SQL management studio you should be able to see the new table in the list of tables in the database your Site Manager is connecting to and the DATABASE version field in the POSISINFO table should be incremented to the number of your script.

 

Next lesson you learn to create graphical user interface in your plugin: Lesson 5 - Plugins: views, tabs and dialogs