home *** CD-ROM | disk | FTP | other *** search
/ Datatid 1999 #6 / Datatid_1999-06.iso / internet / Tango352Promo / P.SQL / PTKPKG.1 / SQLSAM32.FRM (.txt) < prev    next >
Encoding:
Visual Basic Form  |  1997-04-14  |  6.3 KB  |  157 lines

  1. VERSION 4.00
  2. Begin VB.Form Form1 
  3.    Caption         =   "Form1"
  4.    ClientHeight    =   4230
  5.    ClientLeft      =   1095
  6.    ClientTop       =   1515
  7.    ClientWidth     =   6720
  8.    Height          =   4635
  9.    Left            =   1035
  10.    LinkTopic       =   "Form1"
  11.    ScaleHeight     =   4230
  12.    ScaleWidth      =   6720
  13.    Top             =   1170
  14.    Width           =   6840
  15. Attribute VB_Name = "Form1"
  16. Attribute VB_Creatable = False
  17. Attribute VB_Exposed = False
  18. Private Sub Form_Activate()
  19.    Call Main
  20. End Sub
  21. Sub Main()
  22. INCLUDE: 'sqlsam32.bas'
  23.    '*************************************************************************
  24.    '**
  25.    '**  Copyright 1996 Pervasive Software Inc. All Rights Reserved
  26.    '**
  27.    '*************************************************************************
  28.    '*************************************************************************
  29.    '   SQLSAM32.FRM
  30.    '     This is a simple sample designed to allow you to confirm your
  31.    '     ability to compile, link, and execute a Scalable SQL application for
  32.    '     your 16-bit target environment using Microsoft Visual Basic.
  33.    '     This program demonstrates the Visual Basic interface for Scalable
  34.    '     SQL for MS Windows, MS NT, and MS Windows 95. It uses SQL-level
  35.    '     level functions to fetch records from the  'university' database
  36.    '     that is included with Scalable SQL.
  37.    '     This program does the following operations on the sample database:
  38.    '     - logs into the database
  39.    '     - gets a cursor
  40.    '     - compiles a select statement
  41.    '     - gets a record
  42.    '     - displays selected portions of the retrieved record
  43.    '     - frees resources
  44.    '     - logs out of the database
  45.    '     IMPORTANT: Be sure to provide the complete path to the sample
  46.    '     database location, as shown below for a particular case.
  47.    '     See 'IMPORTANT', below.
  48.    '     Note concerning string values passed into SSQL APIs
  49.    '     ---------------------------------------------------
  50.    '     A string variable that needs to be passed by reference must have the
  51.    '     ByVal operator applied to it, while other data types do not need the
  52.    '     ByVal operator.  Example:
  53.    '       Declare Function xyz Lib "xyz.dll" ( ByRef myParm As Any ) As Integer
  54.    '       myInt% = 0
  55.    '       Dim myArray( 255 )
  56.    '       myString$ = "hello, there"
  57.    '       xyz( myInt% )              ( 'ByVal' not required )
  58.    '       xyz( myArray(0) )          ( 'ByVal' not required )
  59.    '       xyz( ByVal myString$ )     ( 'ByVal' IS  required )
  60.    '     PROJECT FILES:
  61.    '        - sqlsam32.vbp   Visual Basic Project File
  62.    '        - sqlsam32.frm   SSQL simple sample.
  63.    '        - sqlsam32.bas   SSQL simple sample support file.
  64.    '        - sqlapi32.bas   SSQL Interface File
  65.    '*************************************************************************
  66.    '*************************************************************************
  67.    '  Variables
  68.    '*************************************************************************
  69.    Dim personRecord As PERSON_STRUCT
  70.    UserID$ = Chr$(0)
  71.    Password$ = Chr$(0)
  72.    Reserved% = 0
  73.    '*************************************************************************
  74.    ' IMPORTANT: Set the path to your database here.
  75.    '*************************************************************************
  76.    DDpath$ = "v:\ssql40\demodata"
  77.    DataPath$ = "v:\ssql40\demodata"
  78.    Print "********** Scalable SQL Visual Basic Interface Demo **********"
  79.    Print
  80.    status% = SUCCESS
  81.    loginFlag% = False
  82.    status% = XQLLogin( _
  83.                 ByVal UserID$, _
  84.                 ByVal Password$, _
  85.                 ByVal DDpath$, _
  86.                 ByVal DataPath$, _
  87.                       Reserved%, _
  88.                 0)
  89.    Print "XQLLogin status = "; status%
  90.    '*************************************************************************
  91.    '    Allocate a cursor
  92.    '*************************************************************************
  93.    cursorIDFlag% = False
  94.    If status% = SUCCESS Then
  95.       loginFlag% = True
  96.       status% = XQLCursor( _
  97.                    cursorID%)
  98.       Print "XQLCursor status = "; status%
  99.    End If
  100.    '*************************************************************************
  101.    '    Compile SQL statement
  102.    '*************************************************************************
  103.    If status% = SUCCESS Then
  104.       statement$ = "SELECT * from person where ID = 101135758 "
  105.       statementLen& = Len(statement$)
  106.       Print statement$
  107.       status% = XQLCompile( _
  108.                    cursorID%, _
  109.                    statementLen&, _
  110.              ByVal statement$)
  111.       Print "XQLCompile status = "; status%
  112.    End If
  113.    FETCH_FIRST& = 1
  114.    '*************************************************************************
  115.    '    Fetch a record with single XQLFetch call
  116.    '*************************************************************************
  117.    If status% = SUCCESS Then
  118.       bufferLength& = 515
  119.       recordsRead& = 1
  120.       INTERNAL_FORMAT& = 0
  121.       SPACING_NOT_PERTINENT& = 0
  122.       status% = XQLFetch( _
  123.                    cursorID%, _
  124.                    FETCH_FIRST&, _
  125.                    bufferLength&, _
  126.                    personRecord, _
  127.                    recordsRead&, _
  128.                    INTERNAL_FORMAT&, _
  129.                    SPACING_NOT_PERTINENT5)
  130.       Print "XQLFetch status = "; status%
  131.       If status% <= 0 Then
  132.          Print
  133.          Print "Selected fields from the retrieved record are:"
  134.          Print "Name:       "; personRecord.FirstName$; " "; _
  135.                                personRecord.LastName$
  136.          Print "Country:    "; personRecord.PermCountry$
  137.          Print "Street:     "; personRecord.PermStreet$
  138.          Print "City:       "; personRecord.PermCity$
  139.          Print "State:      "; personRecord.PermState$
  140.          Print "Zip:        "; personRecord.PermZip$
  141.          Print
  142.          status% = 0
  143.       End If
  144.    End If
  145.    If cursorIDFlag% = True Then
  146.       Call XQLFree( _
  147.               cursorID%)
  148.       Print "XQLFree status = "; status%
  149.    End If
  150.    If loginFlag% = True Then
  151.       status% = XQLLogout()
  152.       Print "XQLLogout status = "; status%
  153.    End If
  154.    status% = XQLStop()
  155.    Print "XQLStop status = "; status%
  156. End Sub
  157.