Creating Database Projects with SQL Anywhere Studio, Part 2 - An example of ADO.NET application
(Page 5 of 5 )
Again a rapid application path will be chosen to demonstrate working with Adapter Server Anywhere. The first thing is to start the Database server as discussed previously. Next start an ASP.NET Web application by adding a Web form (default WebForm1.aspx). If you do not see the data controls that were automatically added when iAnywhere software was installed as shown in the next picture,

you must then right click on the Data tab in the Toolbox and select Add/remove items from the pop-up menu. This will open a dialogue where you can add these items as shown here.

Now drag the AsaConnection object to the WebForm1's design plane. This will add an AsaConnection1 control to the tray below the design plane as shown. Also observe the automatic entries in the properties window.

Now drag an AsaCommand control from the Toolbox to the design plane of WebForm1. aspx. This will add an instance AsaCommand1 of asaCommand object.

In the above dialog, right click on the CommandText, which opens the following Command Text builder tool. You can enter the SQL Statement here as shown. You may execute the statement and see the results. Click OK to this, and the command will execute when called against the database using this statement

Now add a command button which has the following text in this example, "Get Customers from MN." Add also a DataGrid from Toolbox to the design plane to display the results. To the click event of this button, add the following code.
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.
EventArgs) Handles Button1.Click
AsaConnection1.Open()
'give full reference to object
Dim dr As iAnywhere.Data.AsaClient.AsaDataReader
dr = AsaCommand1.ExecuteReader
DataGrid1.DataSource = dr
DataGrid1.DataBind()
End Sub

Build the project, right click webForm1.aspx, and select View in Browser. If everything is working as it should, the following output may be seen in the browser.

Summary
Easy to use Adaptive Server Anywhere adapts itself (no pun intended) extremly well, and integrates well with Microsoft products Excel, VB 6.0, and VB.Net. The server software supports the creation of database objects by providing the necessary hooks in terms of design time controls, once the proper reference is established. Although extremely simple cases of database projects were considered, it should be relatively easy to create projects which manipulate data on the server.
| DISCLAIMER: The content provided in this article is not warranted or guaranteed by Developer Shed, Inc. The content provided is intended for entertainment and/or educational purposes in order to introduce to the reader key ideas, concepts, and/or product reviews. As such it is incumbent upon the reader to employ real-world tactics for security and implementation of best practices. We are not liable for any negative consequences that may result from implementing any information covered in our articles or tutorials. If this is a hardware review, it is not recommended to open and/or modify your hardware. |