Page 1084
One of the more interesting features of the SQLWindows model of inheritance is the concept of class variables. SAL distinguishes these from instance
In fact, the concept of constructors and destructors is not really a part of visual objects either. Visual objects simply have the capability to respond to the Windows messages WM_CREATE and WM_DESTROY, which are represented by SAL as SAM_Create and SAM_Destroy. By defining Message Actions to respond to these messages, the rough equivalents of constructors and destructors can be created.
{% if main.adsdop %}{% include 'adsenceinline.tpl' %}{% endif %}
Another feature of SAL that seems somewhat at odds with the object-oriented model is the fact that all data members and member functions are public (except for variables declared within functions). It would also seem that the programmer should be able to declare variables within Message Actions, which are the
Despite a few shortcomings in the object model employed by SQLWindows, the SAL programming language has many powerful features. Perhaps the most useful of these is the capability to create and respond to user-defined messages. A message can be defined as a global constant in the User section and sent to forms and controls using the SALSendMessage() function. To respond to a
SAL also has very good support for common Windows APIs, including DDE, OLE, and (through QuickObjects) MAPI. You can also use QuickObjects to interface with Lotus Notes and NetWare mail, making it very easy to build messaging capabilities into SQLWindows applications. The outline editor and a few unorthodox features of SAL take some getting used to, but overall, SQLWindows is a serious client/server development tool. It is particularly well-suited to rapid prototyping, through the use of QuickObjects.
Page 1085
Page 1086
Microsoft Visual Basic has become the most popular development tool for
While Visual Basic lacks many of the object-oriented features of its
Among the most comprehensive third-party applications that can quickly jump-start your project is Rapid Application Foundation (RAF) from Advanced Information Systems. RAF is a structured approach to Rapid Application Development. RAF
RAF includes a set of source code libraries consisting of predeveloped code and precoded form templates. The RAF libraries simplify the effort of building any application while providing robust features found only in professional software applications.
RAF enables applications to be prototyped in minutes instead of weeks. The benefit begins as the RAF prototype is optimized with predeveloped foundation libraries, enabling development of world-class client/server applications in record time. Built-in functionality enables your prototype to immediately connect to all ODBC-compliant databases. Connections may be made directly through database procedures, ODBC, or other precoded techniques. Inter- form communication allows an unlimited number of screens, pop-up windows, notes, combo list boxes,
The RAF approach delivers rapid applications for the Windows environment, simplifying window creation through the use of precoded form templates. RAF provides a framework that unifies application coders into a
Page 1087
Advanced Information Systems, Inc. provides on-site skills transfer courses. These courses offer classroom sessions, as well as project development. AIS
This chapter focuses on Visual Basic's ODBC interface, which has relatively few features but is extremely easy to use. In addition, the final section includes a brief summary of the Visual Basic environment and language structure, as well as its strengths and weaknesses.
No additional configuration is required to connect to an ODBC data source from Visual Basic. Any drivers and data sources installed and configured using the ODBC administration program are accessible. The Visual Basic Database object is used to establish connections through its OpenDatabase method. The OpenDatabase method takes four arguments, three of which apply only to local desktop databases:
To connect to Oracle, the connect string requires no special parameters. The code fragment in Listing 48.1 uses values from a generic ODBC login form to build a connect string.
Listing 48.1. The Database object is used to connect to the data source.
Dim dbOracle As Database
Dim szConnect As String
szConnect = "ODBC;DSN=" & lstDSNs.Text & ";"
szConnect = szConnect & "UID=" & txtID.Text & ";"
szConnect = szConnect & "PWD=" & txtPassword.Text & ";"
Set dbOracle = OpenDatabase("", False, False, szConnect)
The connect string
"ODBC;DSN=ORACLE;UID=scotty;PWD=tiger;"
The
Page 1088
The primary means of retrieving results from an ODBC data source is the Snapshot object. The Snapshot object is created using the CreateSnapshot method of the Database object. The CreateSnapshot method takes two arguments: a SQL SELECT statement and a numeric constant used to control processing of the SQL. Unless the application needs to be portable to different RDBMSs, this numeric constant should be set to DB_SQLPASSTHROUGH (64), which sends the statement directly to the server for processing. This mode allows the developer to use the native syntax of the RDBMS, and
Dim dsContacts As Snapshot
Set dsContacts = dbOracle.CreateSnapshot("SELECT a.last_name, a.first_name,
b.phone_nbr FROM individual a, phone b
WHERE a.ID = b.IndividualID(+) ORDER BY 1, 2",
DB_SQLPASSTHROUGH)
The example assumes that the Database object has already connected to the data source. Note that if DB_SQLPASSTHROUGH is not specified, a syntax error results because the local Access engine attempts to parse the SQL and does not recognize the outer join syntax.
After applying the SQL and creating the result set, there are
dsContacts.FindFirst("last_name = `Smith'")
The criteria supplied as the argument to FindFirst are syntactically equivalent to a WHERE clause in SQL. The additional methods FindNext, FindPrevious, and FindLast
After positioning the record pointer, an application can assign
Listing 48.2. The Fields collection is used to access result set data.
Dim iRow As Long iRow = 0 dsContacts.MoveFirst While Not dsContacts.EOF