The Simple project uses the .NET Data Provider to obtain a result set from the database server.
Microsoft Visual Studio
Context and remarks
The Simple project is included with the SQL Anywhere samples. It demonstrates a simple listbox that is filled with the names from the Employees table.
Start Visual Studio.
Click File » Open » Project.
Browse to %SQLANYSAMP12%\SQLAnywhere\ADO.NET\SimpleWin32 and open the Simple.sln project.
When you use the SQL Anywhere .NET Data Provider in a project, you must add a reference to the Data Provider. This has already been done in the Simple code sample. To view the reference to the Data Provider (iAnywhere.Data.SQLAnywhere), open the References folder in the Solution Explorer window.
You must also add a
using directive to your source code to reference the Data Provider classes. This has already been done in the Simple code sample.
To view the
Open the source code for the project. In the Solution Explorer window, right-click Form1.cs and click View Code.
using directives in the top section, you should see the following line:
This line is required for C# projects. If you are using Visual Basic .NET, you need to add an
Imports line to your source code.
Click Debug » Start Without Debugging or press Ctrl+F5 to run the Simple sample.
In the SQL Anywhere Sample window, click Connect.
The application connects to the SQL Anywhere sample database and puts the surname of each employee in the window, as follows:
Close the SQL Anywhere Sample window to shut down the application and disconnect from the sample database. This also shuts down the database server.
The complete application can be found in the SQL Anywhere samples directory at %SQLANYSAMP12%\SQLAnywhere\ADO.NET\SimpleWin32.
Discuter à propos de cette page dans DocCommentXchange.
|Copyright © 2012, iAnywhere Solutions, Inc. - SQL Anywhere 12.0.1|