Purchase |  Products |  Downloads |  Forums |  Blog |  Free Trial     

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

.NET Data Provider

VistaDB..NET Provider is fully compatible with the ADO.NET architecture and provides SQL-92 support for disconnected SQL-based data management, exactly like the SqlClient Provider. The VistaDB .NET Provider components include VistaDBConnection, VistaDBDataAdapter, VistaDBDataReader, VistaDBCommand and each work with databound controls and 3rd party products that support ADO.NET.

C# sample using the VistaDB Data Provider

// Use the VistaDB Data Provider as you would any other Data Provider
// Create a connection to a VistaDB database
VistaDBConnection conn = new VistaDBConnection();
conn.ConnectionString = "Data Source = C:\\MyData\\MyDB.vdb";

// Set up a DataAdapter and Dataset for a table
VistaDBDataAdapter adapterPerson = new VistaDBDataAdapter();
DataSet dsPerson = new DataSet();
adapterPerson.SelectCommand = new VistaDBCommand("SELECT * FROM Person", conn);

// Fill the DataAdapter with data and show it in the grid
dsPerson.Clear();
adapterPerson.Fill(dsPerson,"Person");
gridPerson.DataSource = dsPerson;
gridPerson.DataMember = "Person";

Direct Data Access Objects (DDA)

DDA is unique to VistaDB. DDA consists of 3 .NET objects: VistaDBDatabase, VistaDBTable and the VistaDBDataSet. Together, these objects give you total control over a .VDB database and provide an intuitive, yet powerful object-oriented method of managing data, sometimes referred to as "live cursors" or "navigational control". DDA lets you navigate dynamically through data tables without having to load the entire table or dataset into memory. This gives DDA a big boost in performance over ADO.NET's disconnected data model. See screenshots. The VistaDBDataSet allows DDA to be fully comaptible with all databound controls.

C# sample using the VistaDB DDA objects

// Use the VistaDB Direct Data Access objects
// Create a connection object to a VistaDB database
VistaDBDatabase vDB = new VistaDBDatabase("C:\\MyData\\MyDB.vdb");

// Create a table object
VistaDBTable vTable = new VistaDBTable(vDB);
vTable.TableName = "Person";

// Define local vars to hold the data
string fname;
string lname;
boolean married;
integer age;

// Connect to the database and open the table
vDB.Connect();
vTable.Open();

// Traverse the table to get the records
while( !vTable.EndOfSet() ){
   fname = vTable.GetString( "FirstName");
   lname = vTable.GetString( "LastName");
   married = vTable.GetBoolean( "Married");
   age = vTable.GetInt32( "Age");
   WriteToScreen( fname, lname, married, age);

   // move to the next record
   vTable.Next();
};

// Close our connections
vTable.Close();
vDB.Close();

 Top of page

Win32 VCL components with Delphi

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.

Delphi sample using VistaDB VCL components

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;

 Top of page

Win32 OLE DB Provider with VB

The VistaDB OLE DB Provider provides high-speed ADO/OLE DB data access into a VistaDB database.

VB sample using the VistaDB OLE DB Provider

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

 Top of page

Win32 COM objects with VB

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.

VB sample using VistaDB COM objects

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

 Top of page

Home |  Support |  FAQ |  Testimonials |  Site Map |  Contact Us |  News Archives |  Terms  
 © 1999-2008 VistaDB Software, Inc. All rights reserved.