VB.NET Application with SQL Anywhere 10 database: Part 1

0
138
4 min read

SQL Anywhere 10

SQL Anywhere 10 is the latest version of Sybase’s feature rich SQL Anywhere database technology. It is highly scalable from the small foot-print UltraLite database all the way to its enterprise server with gigabytes of data. It is a comprehensive database package with built-in support for a wide range of applications, including session based synchronization; data exchange with both relational and non-relational data bases; secure store and forward messaging; messaging with FTP and email; and asynchronous access to mobile web services. You may download an evaluation version of the software and take it for a test drive. Sybase Central is a graphical database management interface to the database and its various supporting applications. The integration features are used in this article to create a Windows application retrieving data from the SQL Anywhere 10’s demonstration database, a database which is a part of the default installation of the developer edition.

Overview of SQL Anywhere 10

From Sybase Central you can connect to the demo database quite easily by clicking on the Connections menu item and choosing Connect with SQL Anywhere 10. Figure 1 shows the SQL Anywhere management interface, Sybase Central. Using this interface you may also create an ODBC DSN by following the trail; Tools –> SQL Anywhere 10 –> open ODBC Administrator.

Figure 1

VB.NET Application with SQL Anywhere 10 database: Part 1

It is very easy to connect to the database using the ODBC driver which is provided with the default installation of this product. The Figure 2 shows the User DSN installed with the default installation in the ODBC Data Source Administrator window.

Figure 2

VB.NET Application with SQL Anywhere 10 database: Part 1

The Username is DBA and the Password is sql (case sensitive) for the demo database, demo.db. Please refer to the article, “Migrating from Oracle 10G XE to SQL Anywhere 10” which describes connecting to the demo database in detail. Figure 3 shows the demo database and its objects.

Figure 3

VB.NET Application with SQL Anywhere 10 database: Part 1

VB.NET Windows Application

We will create an ASP.NET 2.0 Windows application called SqlAny. We will create forms which display retrieved data from a table on the database as well as from a stored procedure after accepting a parameter passed to the stored procedure interactively. The Figure 4 shows the details of the project in the Solution Explorer as well as the Object Browser.

Figure 4

VB.NET Application with SQL Anywhere 10 database: Part 1


Accessing SQL Anywhere Explorer

SQL Anywhere Explorer is a component of SQL Anywhere that lets you connect to SQL Anywhere and UltraLite  databases from Visual Studio .NET. From the View menu of Visual Studio, you can access the SQL Anywhere Explorer as shown in Figure 5 – SQL Anywhere 10 is integrated with Visual Studio (both 1.1 and 2.0 versions).

Figure 5

VB.NET Application with SQL Anywhere 10 database: Part 1

Alternatively, you can access SQL Anywhere Explorer from the Tools menu item as shown in Figure 6. In this case the Sybase Central management interface opens in a separate window.

Interactive SQL is another of SQL Anywhere 10’s tools for working with SQL queries on this database.

Figure 6

VB.NET Application with SQL Anywhere 10 database: Part 1

When you click on SQL Anywhere Explorer from the View menu, you will be lead to the following window shown in Figure 7 which allows you to establish a data connection.

Figure 7

VB.NET Application with SQL Anywhere 10 database: Part 1

Click on the drop-down, Add Connection, which opens the window shown in Figure 8 where you will be given a choice of two connections that you may connect to, SQL Anywhere or UltraLite. These are both databases. Both can run on mobile devices, but UltraLite has a smaller footprint.

Figure 8

VB.NET Application with SQL Anywhere 10 database: Part 1

By choosing to connect to SQL Anywhere you invoke the authentication window for making the connection, as shown in Figure 9. The Username is DBA and the Password is sql. After entering these values you can get to the ODBC DSN mentioned earlier, from the drop-down. You may also test the connectivity which you see as being a success, for the entered values of Username, Password, and ODBC DSN.

Figure 9

VB.NET Application with SQL Anywhere 10 database: Part 1

Visual Studio makes a data connection as shown in Figure 10. The nodes for Tables, Views, and Procedures are all expanded in this figure showing all the objects that can be accessed on this database. Since we logged in as DBA, all permissions are in place.

Figure 10

VB.NET Application with SQL Anywhere 10 database: Part 1

Before the connection is made, SQL Anywhere starts up as shown in Figure 11. This message console gets minimized and stays up in the system tray of the desktop. This can be restored and closed by activating the icon in the tray.

Figure 11

VB.NET Application with SQL Anywhere 10 database: Part 1

LEAVE A REPLY

Please enter your comment!
Please enter your name here