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.
To use the ADO.NET Sample, you must have the Microsoft .NET Compact Framework version 2.0 or 3.0 installed on your device. The Microsoft .NET Compact Framework version 2.0 is included with Windows Mobile 6 devices, but not with Windows Mobile 5 devices. The ADO.NET Sample supports only Windows Mobile Classic and Professional devices with touch screens.
The source code for this sample is located in %SQLANYSAMP12%\SQLAnywhere\ce\ado_net_sample.
You can load this project in Microsoft Visual Studio from %SQLANYSAMP12%\SQLAnywhere\ce\ado_net_sample\ado_net_sample.sln.
To download this component from the Microsoft Download Center, go to http://www.microsoft.com/downloads/search.aspx?displaylang=en.
In the ADO.NET Sample user interface, SQL statements must be entered on a single line.
Tap Start » Programs » SQLAny12 » ADO.NET Sample.
Tap Connect.
If the SQL Anywhere database server has not been started earlier, then tapping Connect will cause the server to start.
Tap Exec SQL to execute the default SQL statement, SELECT * FROM Employees.
Data from the Employees table appears in the data window.
Navigate through the data in the Employees table using the scroll bars on the side and bottom of the data window.
Type the following query that accesses a more specific range of data:
SELECT EmployeeID, Surname FROM Employees; |
Tap Exec SQL to execute the SQL statement.
The specified range of data replaces the data that was in the data pane.
Type SELECT * FROM Employees ORDER BY EmployeeID and tap Exec SQL.
Notice the employee Matthew Cobb, with EmployeeID 105.
Type UPDATE Employees SET Surname = 'Jones' WHERE Surname = 'Cobb', and then tap Exec SQL to execute the SQL statement.
Type SELECT * FROM Employees ORDER BY EmployeeID and tap Exec SQL.
Notice that Matthew's last name has been changed from Cobb to Jones.
Type UPDATE Employees SET Surname = 'Cobb' WHERE Surname = 'Jones' and then tap Exec SQL to reverse the change you made to the sample database.
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.
Access data from another table by typing SELECT * FROM Customers, and then tapping Exec SQL.
All the data from the Customers table appears in the data window, replacing the data from the Employees table.
Disconnect from the database server by tapping Disconnect.
The ADO.NET Sample disconnects. The database server does not automatically shut down because the connection is pooled.
Close the ADO.NET Sample by tapping x in the top right corner of the window.
Discuss this page in DocCommentXchange.
|
Copyright © 2012, iAnywhere Solutions, Inc. - SQL Anywhere 12.0.1 |