home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Chip 1997 January
/
Chip_1997-01_cd.bin
/
ms95
/
disk22
/
dir08
/
f000700.re_
/
f000700.re
Wrap
Text File
|
1996-04-02
|
4KB
|
117 lines
' Basic program to create and manipulate table
'
'--------------------------------------------------------------------
'
' Copyright (1995) Bentley Systems, Inc., All rights reserved.
'
' $Workfile: dbquery.bas $
' $Revision: 6.0 $
' $Date: 05 Sep 1995 11:25:12 $
'
' "MicroStation" is a registered trademark of Bentley Systems, Inc.
'
' Limited permission is hereby granted to reproduce and modify this
' copyrighted material provided that the resulting code is used only
' in conjunction with Bentley Systems products under the terms of the
' license agreement provided therein, and that this notice is retained
' in its entirety in any such reproduction or modification.
'
'--------------------------------------------------------------------
'-------------------------------------------------------------
'
' main - Entry point
'
'-------------------------------------------------------------
Sub main
dim tb as New MbeTable
dim sqlda as New MbeSqlda
'-- create a new table
tb.name = "mbe001"
tb.create "firstname char(20), lastname char(20), mslink int"
'-- insert 10 records
'-- insert records by specifying values in the same order as that of fields
tb.recordInsert "'Mark', 'Smith',1"
tb.recordInsert "'Alex', 'Farmer',2"
tb.recordInsert "'Michael', 'Smith',3"
tb.recordInsert "'Susan', 'Smith',4"
tb.recordInsert "'Brian', 'Jacobs', 5"
'--- insert by values and in any order
tb.recordInsert "mslink, firstname, lastname values 6, 'Bill', 'Brown'"
tb.recordInsert "mslink, firstname, lastname values 7, 'Tim', 'Best'"
tb.recordInsert "mslink, firstname, lastname values 8, 'Brad', 'Miller'"
tb.recordInsert "firstname,lastname, mslink values 'Tom','Brown', 9"
tb.recordInsert "firstname,lastname, mslink values 'Matt','Smith', 10"
'---- create a query
tb.criteria = "where lastName = 'Smith'"
If tb.recordFirst(sqlda) = MBE_Success Then
'--- output the result
print "Last Name : Smith"
print tab(2); "First Name"; tab(24); "mslink"
Do
print tab(2);sqlda.value(0);tab(24);sqlda.value(2)
Loop while tb.recordNext (sqlda) = MBE_Success
End If
'---- create another query
tb.criteria = "firstname, lastname where mslink > 5"
If tb.recordFirst(sqlda) = MBE_Success Then
print
print "Query #2: mslink > 5"
print "Name"
Do
print sqlda.value(0);" ";sqlda.value(1)
Loop while tb.recordNext (sqlda) = MBE_Success
End If
'--- update records #5 and #6
tb.recordUpdate 5, "firstname='Robert', lastname='Medlock'"
tb.recordUpdate 6, "lastname='Gayle'"
'--- delete record #10
tb.recordDelete 10
'-- find the current last record
tb.criteria = ""
If tb.recordLast(sqlda) = MBE_Success Then
print
print "Query #3: last record after delete"
print tab(2);"Name";tab(44);"mslink"
print tab(2);sqlda.value(0);" ";sqlda.value(1);tab(44);sqlda.value(2)
End If
'-- report all the records
If tb.recordFirst(sqlda) = MBE_Success Then
print
print "Query #4"
print tab(2);"Name";tab(44);"mslink"
Do
print tab(2);sqlda.value(0);" ";sqlda.value(1);tab(44);sqlda.value(2)
Loop while tb.recordNext (sqlda) = MBE_Success
End If
'--- drop the table
tb.drop
End sub