Login ProductsSalesSupportDownloadsAbout |
Home » Technical Support » ElevateDB Technical Support » Technical Articles » Deploying ElevateDB Applications |
Environment | Requirements |
Delphi C++Builder Lazarus | All three development environments use the VCL (Delphi and C++Builder) or LCL (Lazarus) component framework, both of which allow for the compilation of the ElevateDB engine directly into the client application, or distribution of the ElevateDB engine as a single runtime package. Most developers using these environments choose to compile ElevateDB directly into the application. No external configuration or registry keys/values are required. |
Visual Studio | ElevateDB can be used with any supported .NET language under Visual Studio, and is provided as a standard .NET Data Provider in a single .NET assembly (elevate.elevatedb.data.dll). No external configuration or registry keys/values are required unless one wants to use the database-agnostic factory classes in .NET, in which case a single entry in the machine.config file for the applicable .NET framework is required. |
ODBC Applications | ElevateDB is available as an ODBC driver that can be used with any ODBC-compliant development environment. The ElevateDB ODBC driver is provided as a single native Win32 DLL (edbodbc.dll). Several registry keys/values are required in order for the driver to be properly used with any Windows installation. |
<system.data> <DbProviderFactories> <add name="ElevateDB Data Provider" invariant="Elevate.ElevateDB.Data" description="ElevateDB 2 .Net Data Provider" type="Elevate.ElevateDB.Data.EDBProviderFactory, Elevate.ElevateDB.Data, Version=2.3.14.0, Culture=neutral, PublicKeyToken=cf9bc1202c75e9e2"/> </DbProviderFactories> </system.data>
C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727 C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319
Windows Registry Editor Version 5.00 [HKEY_LOCAL_MACHINE\SOFTWARE\ODBC\ODBCINST.INI] [HKEY_LOCAL_MACHINE\SOFTWARE\ODBC\ODBCINST.INI\ElevateDB 2 ODBC Driver] "APILevel"="3.00" "ConnectFunctions"="YYY" "Driver"="<InstallDir>\\edbodbc.dll" "DriverODBCVer"="03.00" "FileExtns"="*.EDBTbl,*.EDBIdx,*.EDBBlb" "FileUsage"="1" "SQLLevel"="0" "Setup"="<InstallDir>\\edbodbc.dll" "UsageCount"=dword:00000001 [HKEY_LOCAL_MACHINE\SOFTWARE\ODBC\ODBCINST.INI\ODBC Drivers] "ElevateDB 2 ODBC Driver"="Installed"
Method | Benefits |
During Installation | Faster startup time for application No potential for conflicts in a multi-user, file-sharing installation |
During Application Startup | Application can respond to, and correct, configuration issues immediately Application can automatically upgrade configuration and database(s) to new versions |
<InstallDir>\examples\cdcollector\source
const COLLATION = 'ANSI'; procedure TCDCollectorDataModule.CDCollectorEngineBeforeStart(Sender: TObject); begin { Always be sure to set ConfigPath property to correct location. TempTablesPath property is where temporary tables are stored } with CDCollectorEngine do begin ConfigPath:=ExtractFilePath(Application.ExeName); TempTablesPath:=GetTempTablesPath; end; end; procedure TCDCollectorDataModule.DataModuleCreate(Sender: TObject); begin { Activate the engine. The engine can also be referenced by the generic Engine variable in the edbcomps unit } CDCollectorEngine.Active:=True; { Now connect the session } CDCollectorSession.Connected:=True; { Check to see if the database exists or whether it needs to be created } with ConfigurationQuery do begin SQL.Text:='SELECT * FROM Databases WHERE Name='+Engine.QuotedSQLStr('CDCollector'); Open; if (RecordCount=0) then begin { Database doesn't exist and we need to create it } Close; SQL.Text:='CREATE DATABASE "CDCollector" PATH '+ Engine.QuotedSQLStr(ExtractFilePath(Application.ExeName)+'data'); ExecSQL; end else Close; end; { Now we can open the CDCollector database and start to check the metadata for the database. If anything is missing, we create it now in the proper order so as to respect any foreign key <--> primary key RI relationships. NOTE the use of doubled-up single quotes when embedding string constants in the SQL. } with CatalogQuery do begin SQL.Text:='SELECT * FROM Information.Tables WHERE Name=''Artists'''; Open; if (RecordCount=0) then begin Close; SQL.Clear; SQL.Add('CREATE TABLE "Artists"'); SQL.Add('('); SQL.Add('"Name" VARCHAR(30) COLLATE "'+COLLATION+'_CI",'); SQL.Add('"StartedPerforming" INTEGER,'); SQL.Add('"StoppedPerforming" INTEGER,'); SQL.Add('"Comments" CLOB COLLATE "'+COLLATION+'_CI",'); SQL.Add('CONSTRAINT "Name" PRIMARY KEY ("Name")'); SQL.Add(')'); SQL.Add('DESCRIPTION ''Contains artists featured in the CD collection'''); ExecSQL; end else Close; SQL.Text:='SELECT * FROM Information.Tables WHERE Name=''Labels'''; Open; if (RecordCount=0) then begin Close; SQL.Clear; SQL.Add('CREATE TABLE "Labels"'); SQL.Add('('); SQL.Add('"Name" VARCHAR(30) COLLATE "'+COLLATION+'_CI",'); SQL.Add('"Comments" CLOB COLLATE "'+COLLATION+'_CI",'); SQL.Add('CONSTRAINT "Name" PRIMARY KEY ("Name")'); SQL.Add(')'); SQL.Add('DESCRIPTION ''Contains record labels featured in the collection'''); ExecSQL; end else Close; SQL.Text:='SELECT * FROM Information.Tables WHERE Name=''Genres'''; Open; if (RecordCount=0) then begin Close; SQL.Clear; SQL.Add('CREATE TABLE "Genres"'); SQL.Add('('); SQL.Add('"Name" VARCHAR(20) COLLATE "'+COLLATION+'_CI",'); SQL.Add('"Comments" CLOB COLLATE "'+COLLATION+'_CI",'); SQL.Add('CONSTRAINT "Name" PRIMARY KEY ("Name")'); SQL.Add(')'); SQL.Add('DESCRIPTION ''Contains genres featured in the CD collection'''); ExecSQL; end else Close; SQL.Text:='SELECT * FROM Information.Tables WHERE Name=''Albums'''; Open; if (RecordCount=0) then begin Close; SQL.Clear; SQL.Add('CREATE TABLE "Albums"'); SQL.Add('('); SQL.Add('"No" INTEGER GENERATED ALWAYS AS IDENTITY (START WITH 0, INCREMENT BY 1),'); SQL.Add('"Name" VARCHAR(50) COLLATE "'+COLLATION+'_CI" UNIQUE,'); SQL.Add('"Artist" VARCHAR(30) COLLATE "'+COLLATION+'_CI" NOT NULL,'); SQL.Add('"Genre" VARCHAR(20) COLLATE "'+COLLATION+'_CI" NOT NULL,'); SQL.Add('"Year" INTEGER NOT NULL,'); SQL.Add('"Label" VARCHAR(30) COLLATE "'+COLLATION+'_CI" NOT NULL,'); SQL.Add('"Imported" BOOLEAN DEFAULT FALSE NOT NULL,'); SQL.Add('"NumDiscs" INTEGER DEFAULT 1 NOT NULL,'); SQL.Add('"CoverArt" BLOB COMPRESSION 6,'); SQL.Add('"Comments" CLOB COLLATE "'+COLLATION+'_CI",'); SQL.Add('"PurchasedOn" DATE,'); SQL.Add('"PurchasePrice" DECIMAL(20,2),'); SQL.Add('CONSTRAINT "No" PRIMARY KEY ("No"),'); SQL.Add('CONSTRAINT "Artist" FOREIGN KEY ("Artist") REFERENCES "Artists" ("Name"),'); SQL.Add('CONSTRAINT "Genre" FOREIGN KEY ("Genre") REFERENCES "Genres" ("Name"),'); SQL.Add('CONSTRAINT "Label" FOREIGN KEY ("Label") REFERENCES "Labels" ("Name")'); SQL.Add(')'); SQL.Add('DESCRIPTION ''Contains CD albums in the collection'''); ExecSQL; end else Close; SQL.Text:='SELECT * FROM Information.Tables WHERE Name=''Tracks'''; Open; if (RecordCount=0) then begin Close; SQL.Clear; SQL.Add('CREATE TABLE "Tracks"'); SQL.Add('('); SQL.Add('"AlbumNo" INTEGER,'); SQL.Add('"DiscNo" INTEGER,'); SQL.Add('"TrackNo" INTEGER,'); SQL.Add('"TrackName" VARCHAR(50) COLLATE "'+COLLATION+'_CI" NOT NULL,'); SQL.Add('"Length" INTERVAL MINUTE TO SECOND NOT NULL,'); SQL.Add('"Comments" CLOB COLLATE "'+COLLATION+'_CI",'); SQL.Add('CONSTRAINT "TrackNo" PRIMARY KEY ("AlbumNo", "DiscNo", "TrackNo"),'); SQL.Add('CONSTRAINT "Album" FOREIGN KEY ("AlbumNo") REFERENCES "Albums" ("No")'); SQL.Add(')'); SQL.Add('DESCRIPTION ''Contains CD album tracks'''); ExecSQL; end else Close; SQL.Text:='SELECT * FROM Information.Views WHERE Name=''PurchaseInformation'''; Open; if (RecordCount=0) then begin Close; SQL.Clear; SQL.Add('CREATE VIEW "PurchaseInformation" AS'); SQL.Add('SELECT COUNT(Name) AS NumAlbums,'); SQL.Add('SUM(PurchasePrice) AS TotalPurchases,'); SQL.Add('AVG(PurchasePrice) AS AveragePurchasePrice'); SQL.Add('FROM Albums'); SQL.Add('DESCRIPTION ''Total number of albums, purchase price, and average purchase price for the CD collection'''); ExecSQL; end else Close; SQL.Text:='SELECT * FROM Information.Views WHERE Name=''PurchaseHistory'''; Open; if (RecordCount=0) then begin Close; SQL.Clear; SQL.Add('CREATE VIEW "PurchaseHistory" AS'); SQL.Add('SELECT EXTRACT(YEAR FROM PurchasedOn) AS Year,'); SQL.Add('COUNT(Name) AS NumAlbums,'); SQL.Add('SUM(PurchasePrice) AS TotalPurchases'); SQL.Add('FROM Albums'); SQL.Add('GROUP BY Year'); SQL.Add('DESCRIPTION ''History of album purchases by year'''); ExecSQL; end else Close; SQL.Text:='SELECT * FROM Information.Views WHERE Name=''ListeningTimes'''; Open; if (RecordCount=0) then begin Close; SQL.Clear; SQL.Add('CREATE VIEW "ListeningTimes" AS'); SQL.Add('SELECT Albums.No,'); SQL.Add('Albums.Name,'); SQL.Add('Albums.Artist,'); SQL.Add('COUNT(Tracks.TrackNo) AS NumTracks,'); SQL.Add('AVG(Tracks.Length) AS AvgLength,'); SQL.Add('CAST(SUM(Tracks.Length) AS INTERVAL HOUR TO SECOND) AS TotalTime'); SQL.Add('FROM Albums INNER JOIN Tracks ON Tracks.AlbumNo=Albums.No'); SQL.Add('GROUP BY Albums.No'); SQL.Add('ORDER BY Albums.Name'); SQL.Add('DESCRIPTION ''Total listening times in hours, minutes, and seconds for each album'''); ExecSQL; end else Close; SQL.Text:='SELECT * FROM Information.Procedures WHERE Name=''Summaries'''; Open; if (RecordCount=0) then begin Close; SQL.Clear; SQL.Add('CREATE PROCEDURE Summaries(IN "SummaryType" CHAR(1) COLLATE "'+COLLATION+'_CI")'); SQL.Add('BEGIN'); SQL.Add('DECLARE Result CURSOR WITH RETURN FOR Stmt;'); SQL.Add(''); SQL.Add('CASE SummaryType'); SQL.Add('-- Genres summary'); SQL.Add('WHEN ''G'' THEN'); SQL.Add(' BEGIN'); SQL.Add(' PREPARE Stmt FROM ''SELECT Genre AS Name, COUNT(Name) AS NumAlbums,'); SQL.Add(' SUM(PurchasePrice) AS TotalPurchases'); SQL.Add(' FROM Albums'); SQL.Add(' GROUP BY Genre'';'); SQL.Add(' OPEN Result;'); SQL.Add(' END;'); SQL.Add('-- Labels summary'); SQL.Add('WHEN ''L'' THEN'); SQL.Add(' BEGIN'); SQL.Add(' PREPARE Stmt FROM ''SELECT Label AS Name, COUNT(Name) AS NumAlbums,'); SQL.Add(' SUM(PurchasePrice) AS TotalPurchases'); SQL.Add(' FROM Albums'); SQL.Add(' GROUP BY Label'';'); SQL.Add(' OPEN Result;'); SQL.Add(' END;'); SQL.Add('-- Artists summary'); SQL.Add('WHEN ''A'' THEN'); SQL.Add(' BEGIN'); SQL.Add(' PREPARE Stmt FROM ''SELECT Artist AS Name, COUNT(Name) AS NumAlbums,'); SQL.Add(' SUM(PurchasePrice) AS TotalPurchases'); SQL.Add(' FROM Albums'); SQL.Add(' GROUP BY Artist'';'); SQL.Add(' OPEN Result;'); SQL.Add(' END;'); SQL.Add('END CASE;'); SQL.Add('END'); SQL.Add('DESCRIPTION ''Produces a summary of the number of albums and total album purchases by genre, label, or artist'''); ExecSQL; end else Close; end; end;
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Windows.Forms; using System.IO; using Elevate.ElevateDB.Data; namespace CDCollector { class DataModule { public DataModule() { String ApplicationPath = Path.GetDirectoryName(Application.ExecutablePath); String CRLF = "\r\n"; // Set up the connection - notice that we're using the system-defined Configuration database initially EDBConnection DataConnection = new EDBConnection(@"TYPE=LOCAL;" + "CONFIGPATH=" + ApplicationPath + ";" + "DATABASE=Configuration;" + "UID=Administrator;" + "PWD=EDBDefault"); // Open the connection DataConnection.Open(); EDBCommand DataCommand = new EDBCommand(); DataCommand.Connection = DataConnection; // Check to see if the database exists or whether it needs to be created DataCommand.CommandText = "SELECT * FROM Databases WHERE Name='CDCollector'"; if (DataCommand.Execute() == 0) { // Database doesn't exist and we need to create it DataCommand.CommandText = "CREATE DATABASE CDCollector PATH '" + ApplicationPath + Path.DirectorySeparatorChar + "data'"; DataCommand.ExecuteNonQuery(); } // Now we can open the CDCollector database and start to check the metadata for // the database. If anything is missing, we create it now in the proper order // so as to respect any foreign key <--> primary key RI relationships. DataConnection.ChangeDatabase("CDCollector"); DataCommand.CommandText = "SELECT * FROM Information.Tables WHERE Name='Artists'"; if (DataCommand.Execute() == 0) { DataCommand.CommandText = "CREATE TABLE Artists " + CRLF + "( " + CRLF + "Name VARCHAR(30) COLLATE UNI_CI, " + CRLF + "StartedPerforming INTEGER, " + CRLF + "StoppedPerforming INTEGER, " + CRLF + "Comments CLOB COLLATE UNI_CI, " + CRLF + "CONSTRAINT Name PRIMARY KEY (Name)" + ")" + "DESCRIPTION 'Contains artists featured in the CD collection'"; DataCommand.ExecuteNonQuery(); } DataCommand.CommandText = "SELECT * FROM Information.Tables WHERE Name='Labels'"; if (DataCommand.Execute() == 0) { DataCommand.CommandText = "CREATE TABLE Labels " + CRLF + "( " + CRLF + "Name VARCHAR(30) COLLATE UNI_CI, " + CRLF + "Comments CLOB COLLATE UNI_CI, " + CRLF + "CONSTRAINT Name PRIMARY KEY (Name) " + CRLF + ") " + CRLF + "DESCRIPTION 'Contains record labels featured in the collection'"; DataCommand.ExecuteNonQuery(); } DataCommand.CommandText = "SELECT * FROM Information.Tables WHERE Name='Genres'"; if (DataCommand.Execute() == 0) { DataCommand.CommandText = "CREATE TABLE Genres " + CRLF + "( " + CRLF + "Name VARCHAR(20) COLLATE UNI_CI, " + CRLF + "Comments CLOB COLLATE UNI_CI, " + CRLF + "CONSTRAINT Name PRIMARY KEY (Name) " + CRLF + ") " + CRLF + "DESCRIPTION 'Contains genres featured in the CD collection'"; DataCommand.ExecuteNonQuery(); } DataCommand.CommandText = "SELECT * FROM Information.Tables WHERE Name='Albums'"; if (DataCommand.Execute() == 0) { DataCommand.CommandText = "CREATE TABLE Albums " + CRLF + "( " + CRLF + "No INTEGER GENERATED ALWAYS AS IDENTITY (START WITH 0, INCREMENT BY 1), " + CRLF + "Name VARCHAR(50) COLLATE UNI_CI UNIQUE, " + CRLF + "Artist VARCHAR(30) COLLATE UNI_CI NOT NULL, " + CRLF + "Genre VARCHAR(20) COLLATE UNI_CI NOT NULL, " + CRLF + "Year INTEGER NOT NULL, " + CRLF + "Label VARCHAR(30) COLLATE UNI_CI NOT NULL, " + CRLF + "Imported BOOLEAN DEFAULT FALSE NOT NULL, " + CRLF + "NumDiscs INTEGER DEFAULT 1 NOT NULL, " + CRLF + "CoverArt BLOB COMPRESSION 6, " + CRLF + "Comments CLOB COLLATE UNI_CI, " + CRLF + "PurchasedOn DATE, " + CRLF + "PurchasePrice DECIMAL(20,2), " + CRLF + "CONSTRAINT No PRIMARY KEY (No), " + CRLF + "CONSTRAINT Artist FOREIGN KEY (Artist) REFERENCES Artists (Name), " + CRLF + "CONSTRAINT Genre FOREIGN KEY (Genre) REFERENCES Genres (Name), " + CRLF + "CONSTRAINT Label FOREIGN KEY (Label) REFERENCES Labels (Name) " + CRLF + ") " + CRLF + "DESCRIPTION 'Contains CD albums in the collection'"; DataCommand.ExecuteNonQuery(); } DataCommand.CommandText = "SELECT * FROM Information.Tables WHERE Name='Tracks'"; if (DataCommand.Execute() == 0) { DataCommand.CommandText = "CREATE TABLE Tracks " + CRLF + "( " + CRLF + "AlbumNo INTEGER, " + CRLF + "DiscNo INTEGER, " + CRLF + "TrackNo INTEGER, " + CRLF + "TrackName VARCHAR(50) COLLATE UNI_CI NOT NULL, " + CRLF + "Length INTERVAL MINUTE TO SECOND NOT NULL, " + CRLF + "Comments CLOB COLLATE UNI_CI, " + CRLF + "CONSTRAINT TrackNo PRIMARY KEY (AlbumNo, DiscNo, TrackNo), " + CRLF + "CONSTRAINT Album FOREIGN KEY (AlbumNo) REFERENCES Albums (No) " + CRLF + ") " + CRLF + "DESCRIPTION 'Contains CD album tracks'"; DataCommand.ExecuteNonQuery(); } DataCommand.CommandText = "SELECT * FROM Information.Views WHERE Name='PurchaseInformation'"; if (DataCommand.Execute() == 0) { DataCommand.CommandText = "CREATE VIEW PurchaseInformation AS " + CRLF + "SELECT COUNT(Name) AS NumAlbums, " + CRLF + "SUM(PurchasePrice) AS TotalPurchases, " + CRLF + "AVG(PurchasePrice) AS AveragePurchasePrice " + CRLF + "FROM Albums " + CRLF + "DESCRIPTION 'Total number of albums, purchase price, and average purchase price for the CD collection'"; DataCommand.ExecuteNonQuery(); } DataCommand.CommandText = "SELECT * FROM Information.Views WHERE Name='PurchaseHistory'"; if (DataCommand.Execute() == 0) { DataCommand.CommandText = "CREATE VIEW PurchaseHistory AS " + CRLF + "SELECT EXTRACT(YEAR FROM PurchasedOn) AS Year, " + CRLF + "COUNT(Name) AS NumAlbums, " + CRLF + "SUM(PurchasePrice) AS TotalPurchases " + CRLF + "FROM Albums " + CRLF + "GROUP BY Year " + CRLF + "DESCRIPTION 'History of album purchases by year'"; DataCommand.ExecuteNonQuery(); } DataCommand.CommandText = "SELECT * FROM Information.Views WHERE Name='ListeningTimes'"; if (DataCommand.Execute() == 0) { DataCommand.CommandText = "CREATE VIEW ListeningTimes AS " + CRLF + "SELECT Albums.No, " + CRLF + "Albums.Name, " + CRLF + "Albums.Artist, " + CRLF + "COUNT(Tracks.TrackNo) AS NumTracks, " + CRLF + "AVG(Tracks.Length) AS AvgLength, " + CRLF + "CAST(SUM(Tracks.Length) AS INTERVAL HOUR TO SECOND) AS TotalTime " + CRLF + "FROM Albums INNER JOIN Tracks ON Tracks.AlbumNo=Albums.No " + CRLF + "GROUP BY Albums.No " + CRLF + "ORDER BY Albums.Name " + CRLF + "DESCRIPTION 'Total listening times in hours, minutes, and seconds for each album'"; DataCommand.ExecuteNonQuery(); } DataCommand.CommandText = "SELECT * FROM Information.Procedures WHERE Name='Summaries'"; if (DataCommand.Execute() == 0) { DataCommand.CommandText = "CREATE PROCEDURE Summaries(IN SummaryType CHAR(1) COLLATE UNI_CI) " + CRLF + "BEGIN " + CRLF + "DECLARE Result CURSOR WITH RETURN FOR Stmt; " + CRLF + "" + "CASE SummaryType " + CRLF + "-- Genres summary " + CRLF + "WHEN 'G' THEN " + CRLF + " BEGIN " + CRLF + " PREPARE Stmt FROM 'SELECT Genre AS Name, COUNT(Name) AS NumAlbums, " + CRLF + " SUM(PurchasePrice) AS TotalPurchases " + CRLF + " FROM Albums " + CRLF + " GROUP BY Genre'; " + CRLF + " OPEN Result; " + CRLF + " END; " + CRLF + "-- Labels summary " + CRLF + "WHEN 'L' THEN " + CRLF + " BEGIN " + CRLF + " PREPARE Stmt FROM 'SELECT Label AS Name, COUNT(Name) AS NumAlbums, " + CRLF + " SUM(PurchasePrice) AS TotalPurchases " + CRLF + " FROM Albums " + CRLF + " GROUP BY Label'; " + CRLF + " OPEN Result; " + CRLF + " END; " + CRLF + "-- Artists summary " + CRLF + "WHEN 'A' THEN " + CRLF + " BEGIN " + CRLF + " PREPARE Stmt FROM 'SELECT Artist AS Name, COUNT(Name) AS NumAlbums, " + CRLF + " SUM(PurchasePrice) AS TotalPurchases " + CRLF + " FROM Albums " + CRLF + " GROUP BY Artist'; " + CRLF + " OPEN Result; " + CRLF + " END; " + CRLF + "END CASE; " + CRLF + "END " + CRLF + "DESCRIPTION 'Produces a summary of the number of albums and total album purchases by genre, label, or artist'"; DataCommand.ExecuteNonQuery(); } } } }
This web page was last updated on Wednesday, January 13, 2021 at 12:15 AM | Privacy PolicySite Map © 2024 Elevate Software, Inc. All Rights Reserved Questions or comments ? E-mail us at info@elevatesoft.com |