home *** CD-ROM | disk | FTP | other *** search
- VERSION 4.00
- Begin VB.Form Form1
- Caption = "Form1"
- ClientHeight = 4230
- ClientLeft = 1095
- ClientTop = 1515
- ClientWidth = 6720
- Height = 4635
- Left = 1035
- LinkTopic = "Form1"
- ScaleHeight = 4230
- ScaleWidth = 6720
- Top = 1170
- Width = 6840
- Attribute VB_Name = "Form1"
- Attribute VB_Creatable = False
- Attribute VB_Exposed = False
- Private Sub Form_Activate()
- Call Main
- End Sub
- Sub Main()
- INCLUDE: 'sqlsam32.bas'
- '*************************************************************************
- '**
- '** Copyright 1996 Pervasive Software Inc. All Rights Reserved
- '**
- '*************************************************************************
- '*************************************************************************
- ' SQLSAM32.FRM
- ' This is a simple sample designed to allow you to confirm your
- ' ability to compile, link, and execute a Scalable SQL application for
- ' your 16-bit target environment using Microsoft Visual Basic.
- ' This program demonstrates the Visual Basic interface for Scalable
- ' SQL for MS Windows, MS NT, and MS Windows 95. It uses SQL-level
- ' level functions to fetch records from the 'university' database
- ' that is included with Scalable SQL.
- ' This program does the following operations on the sample database:
- ' - logs into the database
- ' - gets a cursor
- ' - compiles a select statement
- ' - gets a record
- ' - displays selected portions of the retrieved record
- ' - frees resources
- ' - logs out of the database
- ' IMPORTANT: Be sure to provide the complete path to the sample
- ' database location, as shown below for a particular case.
- ' See 'IMPORTANT', below.
- ' Note concerning string values passed into SSQL APIs
- ' ---------------------------------------------------
- ' A string variable that needs to be passed by reference must have the
- ' ByVal operator applied to it, while other data types do not need the
- ' ByVal operator. Example:
- ' Declare Function xyz Lib "xyz.dll" ( ByRef myParm As Any ) As Integer
- ' myInt% = 0
- ' Dim myArray( 255 )
- ' myString$ = "hello, there"
- ' xyz( myInt% ) ( 'ByVal' not required )
- ' xyz( myArray(0) ) ( 'ByVal' not required )
- ' xyz( ByVal myString$ ) ( 'ByVal' IS required )
- ' PROJECT FILES:
- ' - sqlsam32.vbp Visual Basic Project File
- ' - sqlsam32.frm SSQL simple sample.
- ' - sqlsam32.bas SSQL simple sample support file.
- ' - sqlapi32.bas SSQL Interface File
- '*************************************************************************
- '*************************************************************************
- ' Variables
- '*************************************************************************
- Dim personRecord As PERSON_STRUCT
- UserID$ = Chr$(0)
- Password$ = Chr$(0)
- Reserved% = 0
- '*************************************************************************
- ' IMPORTANT: Set the path to your database here.
- '*************************************************************************
- DDpath$ = "v:\ssql40\demodata"
- DataPath$ = "v:\ssql40\demodata"
- Print "********** Scalable SQL Visual Basic Interface Demo **********"
- Print
- status% = SUCCESS
- loginFlag% = False
- status% = XQLLogin( _
- ByVal UserID$, _
- ByVal Password$, _
- ByVal DDpath$, _
- ByVal DataPath$, _
- Reserved%, _
- 0)
- Print "XQLLogin status = "; status%
- '*************************************************************************
- ' Allocate a cursor
- '*************************************************************************
- cursorIDFlag% = False
- If status% = SUCCESS Then
- loginFlag% = True
- status% = XQLCursor( _
- cursorID%)
- Print "XQLCursor status = "; status%
- End If
- '*************************************************************************
- ' Compile SQL statement
- '*************************************************************************
- If status% = SUCCESS Then
- statement$ = "SELECT * from person where ID = 101135758 "
- statementLen& = Len(statement$)
- Print statement$
- status% = XQLCompile( _
- cursorID%, _
- statementLen&, _
- ByVal statement$)
- Print "XQLCompile status = "; status%
- End If
- FETCH_FIRST& = 1
- '*************************************************************************
- ' Fetch a record with single XQLFetch call
- '*************************************************************************
- If status% = SUCCESS Then
- bufferLength& = 515
- recordsRead& = 1
- INTERNAL_FORMAT& = 0
- SPACING_NOT_PERTINENT& = 0
- status% = XQLFetch( _
- cursorID%, _
- FETCH_FIRST&, _
- bufferLength&, _
- personRecord, _
- recordsRead&, _
- INTERNAL_FORMAT&, _
- SPACING_NOT_PERTINENT5)
- Print "XQLFetch status = "; status%
- If status% <= 0 Then
- Print
- Print "Selected fields from the retrieved record are:"
- Print "Name: "; personRecord.FirstName$; " "; _
- personRecord.LastName$
- Print "Country: "; personRecord.PermCountry$
- Print "Street: "; personRecord.PermStreet$
- Print "City: "; personRecord.PermCity$
- Print "State: "; personRecord.PermState$
- Print "Zip: "; personRecord.PermZip$
- Print
- status% = 0
- End If
- End If
- If cursorIDFlag% = True Then
- Call XQLFree( _
- cursorID%)
- Print "XQLFree status = "; status%
- End If
- If loginFlag% = True Then
- status% = XQLLogout()
- Print "XQLLogout status = "; status%
- End If
- status% = XQLStop()
- Print "XQLStop status = "; status%
- End Sub
-