![]() |
2.1 is no longer sold or supported - these pages are for reference purposes only. VistaDB 3.x should be used for all new development.VistaDB 2.1 Sample Code
|
VistaDB's VCL components are fully Borland TDataSet compatible, which mean they are fully compatible with Borland's and third party data aware controls. The VCL provides high-speed access into a VistaDB database. The VistaDB VCL components include TVDBDatabase, TVDBTable, TVDBQuery and TVDBDirect.
procedure
TryVistaDB;
var
VDBDatabase1:
TVDBDatabase;
VDBQuery1:
TVDBQuery;
fname,lname: string;
age:
integer;
begin
// Use the TVDBQuery
object
// Create a connection object to a
VistaDB database
VDBDatabase1 :=
TVDBDatabase.Create('C:\MyData\MyDB.vdb');
VDBDatabase1.Open;
// Create a query object and open the
SQL
VDBQuery1 :=
TVDBQuery(VDBDatabase1);
VDBQuery1.SQL := 'SELECT * FROM Person WHERE
State = CA';
VDBQuery1.Open;
// Traverse
all the records
while not VDBQuery1.EOF
do
begin
fname =
VDBQuery1.FieldByName('FirstName').AsString;
lname =
VDBQuery1.FieldByName('LastName').AsString;
age =
VDBQuery1.FieldByName('Age').AsInteger;
WriteToScreen(
fname, lname,
age);
VDBQuery1.Next;
end;
VDBQuery1.Close;
VDBDatabase1.Close;
end;
The VistaDB OLE DB Provider provides high-speed ADO/OLE DB data access into a VistaDB database.
procedure TryVistaDB
Adodc1.Connect
= "Provider=VistaDBOLEDB20.VistaDBOLEDB;Database
Name=VistaDBDemoQuery.vdb"
Adodc1.OLEDBString =
"Provider=VistaDBOLEDB20.VistaDBOLEDB;Database Name=VistaDBDemoQuery.vdb"
Adodc1.ConnectionString = "Provider=VistaDBOLEDB20.VistaDBOLEDB;
Database Name= " & CurDir &
"\VistaDBDemoQuery.vdb"
Adodc1.RecordSource = "SELECT * FROM
COMPUTERS"
Adodc1.Refresh
Set DataGrid1.DataSource = Adodc1
end sub
VistaDB's COM objects provides high-speed access to VistaDB databases. The VistaDB COM objects include Database, Table, Query and an Email object for ASP applications.
procedure TryVistaDB
' Create the database connection object
Set
myDB = CreateObject( "VistaDBCOM20.Database" )
'
Switch between ASP and Win32 applications, default is
False
myDB.ASPMode = False
myDB.Directory =
"C:\MyApp\Data"
myDB.DatabaseName =
"Test.VDB"
myDB.Open
' 1. Non-SQL
------------------
' Create the table object,
connect it to the database and open
Set myTable = CreateObject(
"VistaDBCOM20.Table")
myTable.Database =
myDB
myTable.TableName = "Customer"
myTable.Open
' Traverse all the records
while (not
myTable.EOF)
fname =
myTable.GetString("First")
lname =
myTable.GetString("Last")
Response.Write( fname +" "+
lname +
"")
myTable.Next
wend
myTable.Close
Set
myTable = Nothing
' 2. SQL
----------------------
' Create the query
object, connect it to the database and open
Set myQuery =
CreateObject( "VistaDBCOM20.Query")
myQuery.Database =
myDB
myQuery.SQL = "SELECT * FROM
Customer"
myQuery.Open
' Traverse all the
records
while (not myQuery.EOF)
fname =
myQuery.GetString("First")
lname =
myQuery.GetString("Last")
Response.Write( fname +" "+
lname +
"")
myQuery.Next
wend
myQuery.Close
Set
myQuery = Nothing
myDB.Close
Set myDB =
Nothing
end sub
| Home | Support | FAQ | Testimonials | Site Map | Contact Us | News Archives | Terms | |
| © 1999-2008 VistaDB Software, Inc. All rights reserved. |