Define a query

Let’s define a simple query for reading all customer names from a database.
  • Open an existing .dbmodel file or add new from the NSQLObjects template.
  • Check that the connection statement point’s to valid database. If you are using the default NSQLObjects project template, the connection is defined in the Defaults.dbmodel file which should be included in other dbmodel files.
Unless otherwise noted all samples use the Northwind database.
  • Add the following piece of code to a .dbmodel file
query CustomerNames [[
  SELECT CustomerID, CompanyName
  FROM Customers
]];
  • Save the file. This should generate the CustomerNames and CustomerNamesRow classes.

Use a query

Last edited Oct 26, 2010 at 9:46 AM by nolics, version 5

Comments

No comments yet.