Mobile Database Development Tutorial: Part 3
This is third article in a series of four intended to introduce InformIT readers to the basics of mobile database development by using the popular Sybase SQL Anywhere Studio 8 mobile database tools. In my second article, "Mobile Database Development Tutorial: Part 2," we stepped through the various options for Java application developers using this tool suite. In this article, we'll discuss database development using another popular programming language: Visual Basic. This includes the popular Microsoft Visual Basic desktop development languages as well as Microsoft eMbedded Visual Basic for Windows CE and AppForge's MobileVB for Palm OS and the Pocket PC platform.
ADO
It should come as no surprise to Microsoft technology developers to learn that Sybase has provided an ADO (ActiveX Data Objects) interface to Adaptive Server Anywhere, in conjunction with its ASAProv OLE DB Provider and iAnywhere ODBC Drivers for Adaptive Server Anywhere, Sybase Adaptive Server Enterprise (ASE), Oracle, and DB2. The ODBC Driver can be configured using the standard ODBC Data Source Administrator that is probably already installed on your system. Inside the administration tool, click Add... to create a new Data Source to the mobile sales database. Selecting the Adaptive Server Anywhere 8.0 driver produces the ASA ODBC configuration dialog box shown in Figure 1.
Figure 1 Configuring the ASA ODBC connection.
As you can see, I named my local data source MOBILE_SALES, and I'll use this DSN when building the ADO connection to the mobile_sales.db database. Once your DSN is configured, you're ready to begin development. In Microsoft Visual Basic 6.0, references to the ADO 2.5 and ADO Recordset 2.5 libraries need to be added. This can be done by selecting References... from the Project menu inside the Visual Basic IDE. Visual Basic developers (assumedly developing for mobile Windows 2000/XP laptops or tablet computers) can then make use of all ADO objects, including Connection, Recordset, Record, and Field. To create the connection to the running ASA database, standard ADO syntax is used:
Dim rs As ADODB.Recordset conn.Open "Provider=ASAProv;Data Source=MOBILE_SALES;User Id=dba;Password=sql;" Set rs = conn.Execute("select * from CUSTOMER") Do While Not rs.EOF 'Do Something Loop conn.Close Set conn = Nothing