Click here to view and discuss this page in DocCommentXchange. In the future, you will be sent there automatically.

SQL Anywhere 10.0.1 » SQL Anywhere Server - Database Administration » SQL Anywhere for Windows CE » Using the Windows CE sample applications

The SQL Anywhere Server Example Next Page

The ADO.NET Sample


To use the ADO.NET Sample, you must have the Microsoft .NET Compact Framework version 1.0 with Service Pack 2 or higher installed on your device.

You can download this component from the Microsoft Download Center at [external link] http://www.microsoft.com/downloads/search.aspx?displaylang=en.

The ADO.NET Sample demonstrates a simple application that uses the ADO.NET programming interface. This application allows you to start the sample database running on the network database server and access and modify data using SQL statements.

The source code for this sample is located in samples-dir\SQLAnywhere\ce\ado_net_sample.

You can load this project in Visual Studio from samples-dir\SQLAnywhere\ce\ado_net_sample\ado_net_sample.sln.

Note

In the ADO.NET Sample user interface, SQL statements must be entered on a single line.

To use the ADO.NET Sample
  1. Start the ADO.NET Sample by tapping Start > Programs > SQLAny10 > ADO.NET Sample.

  2. Tap Connect.

    The sample database starts on a network database server. The Server Messages window appears briefly, then disappears.

  3. Tap Exec SQL to execute the default SQL statement, SELECT * FROM Employees, and then tap Exec SQL.

    All the data from the Employees table appears in the data window.

  4. Navigate through the data in the Employees table using the scroll bars on the side and bottom of the data window.

  5. Type the following query that accesses a more specific range of data.

    SELECT EmployeeID, Surname FROM Employees
  6. Tap Exec SQL to execute the SQL statement.

    The specified range of data replaces the data that was in the data pane.

  7. Type SELECT * FROM Employees ORDER BY EmployeeID and tap Exec SQL.

    Notice the employee Matthew Cobb, with EmployeeID 105.

  8. Type UPDATE Employees SET Surname = 'Jones' WHERE Surname = 'Cobb', and then tap Exec SQL to execute the SQL statement.

  9. Type SELECT * FROM Employees ORDER BY EmployeeID and tap Exec SQL.

    Notice that Matthew's last name has been changed from Cobb to Jones.

  10. Type UPDATE Employees SET Surname = 'Cobb' WHERE Surname = 'Jones' and then tap Exec SQL to reverse the change you made to the sample database.

  11. Verify that the changes were reversed by typing SELECT * FROM Employees ORDER BY EmployeeID and then tapping Exec SQL.

    Notice that Matthew's last name has been changed back to Cobb.

  12. Access data from another table by typing SELECT * FROM Customers in the Exec SQL field and then tapping Exec SQL.

    All the data from the Customers table appears in the data window, replacing the data from the Employees table.

  13. Shut down the database server by tapping Disconnect.

    The ADO.NET Sample disconnects, and the database server automatically shuts down.

  14. Close the ADO.NET Sample by tapping the × in the top right corner of the window.