Thursday, June 14, 2007

Using TADO Objects

This was a major pain in the neck. The documentation in Borland is not clear; however, I now have something working.

I should mention that I am working with Access 2003 and Borland Builder 6.0 Professional.

For my experience so far I believe the following to be true:
  • There is no way to setup an ADO connection in ODBC (I could be wrong in this but it is not clearly obvious how one would set it up.)
  • Procedures can be created and destroyed. In TQuery they can only be created.
I was able to get the connection string using the Borland ADO controls. The is a helper for building the string and I don't think I could have done what I did without it.

The following test code compiled and ran and worked.

#include

TADOConnection *conn = new TADOConnection( NULL );

conn->ConnectionString =
"Provider=Microsoft.Jet.OLEDB.4.0;"
"Data Source=C:\\LU_IncomingQC_APB.mdb;"
"Persist Security Info=False" ;
conn->Open();
TADOQuery *qry = new TADOQuery( NULL );
qry->Connection = conn;

// Create the procedure to be called
sql = "CREATE PROC createTable "
" (NewTable TEXT) AS "
" CREATE TABLE NewTable "
" ( "
" InvoiceID INTEGER NOT NULL, "
" InvoiceDate DATETIME NOT NULL "
" ); ";

sql = "CREATE PROCEDURE DeleteInvoices AS (DROP TABLE testTable1)";
qry->SQL->Clear();
qry->SQL->Add( sql );
qry->ExecSQL();

sql = "DROP PROC DeleteInvoices;";

qry->SQL->Clear();
qry->SQL->Add( sql );
qry->ExecSQL();

normal

Wednesday, June 6, 2007

TDS File Extentions

Turbo Debugger Symbol Table: http://filext.com/file-extension/TDS

This file should not be managed.

Friday, June 1, 2007

Table Present?

Two ways to test to see if a table is present:

One

The following code will determine is a table is present and delete it.

TDatabase *db = qry->OpenDatabase();
const String TABLE_NAME = "AC130U_061016_corrected";
TStringList *list = new TStringList;
db->GetTableNames( list );
if ( list->IndexOf(TABLE_NAME)>=0 )
{
String s1 = "DROP TABLE [" + TABLE_NAME + "];";
qry->Execute( s1 );
}

The qry is of type TQuery.

Two

bool HasTable=false;

TTable *testTable = new TTable(NULL);
try
{
testTable->DatabaseName = dbase->DatabaseName;
testTable->TableName = TableName;
HasTable = testTable->Exists;
}
__finally
{
delete testTable;
}


Wednesday, May 30, 2007

When to use __fastcall

The __fastcall keyword should be used when a function is expecting parameters to be passed in registers. It must be used for all TForm methods. (see http://www.codepedia.com/1/CppBuilderFastcall)

This guy talks about it in a Win32 sense. He mentions that I buys little in a x86 world because of the limited register set. However, under the x64 calling convention this is not the case. (see http://www.nynaeve.net/?p=63). This guy, Ken Johnson, really seems to know what he is talking about.

Confusing Compiler Error Messages

If I leave the semicolon off a class declaration I get the following set of confusing error messages:

[C++ Warning] QuerySet.cpp(19): W8058 Cannot create pre-compiled header: header incomplete

[C++ Error] QuerySet.cpp(20): E2111 Type 'QuerySet' may not be defined here

[C++ Error] QuerySet.cpp(20): E2136 Constructor cannot have a return type specification

Add the semicolon to the end of the class declaration and all these problems go away.

Friday, May 25, 2007

Database Objects

TTable
TQuery
TStoredProc - store procedure are available in ACCESS since 2000. However, you cannot get to them from the user interface. They must be created.

Tuesday, May 15, 2007

Parameters

A subroutine's parameters can be passed on one of two ways.

  • call by value - copies the value of an argument in to the formal parameter of the subroutine. Changes to the parameter of the subroutine has no effect on the argument used to call it.
  • call by reference - the address of an argument is copied in the parameter. Changes made to the parameter will affect the argument.

Friday, January 5, 2007

Borland C++ Builder Documentation

The Borland C++ Builder documentation.

This includes the quick document and a rather large developer document.

DDP (Delphi Diagram Portfolio) File

I believe that this is a Delphi Diagram Portfolio (DDP) file.

It could also be a distributed development profile file. However, I don't see any interface definition language (IDL) files.

I believe that the DDP file is related to the form (see Google Group message 1)

It seem to be a temporary file (see Google Group message 2)


DFM (Form Designer) Files

The DFM or Form Designer files are binary resource files. They describe the form and all its components. There is a separate DFM file for each form.

Thursday, December 7, 2006

Borland C++ Builder 3 in 21 Days: Day 1

forums.borland.com contains the news groups.

www.borland.com is the company site.

http://www.borland.com/us/products/cbuilder/index.html is the site for the most recent release of Borland C++ Builder.

http://www.mcp.com/info cannot be found.

A Quick Look at the C++ Builder
integrated development environment (IDE)


Top of screen is the main window. It contains a toolbar to the left and a Component palette on the right.

component - a self-contained binary piece of software that performs some specific predefined function.

Object Inspector (bottom left)

property - determines the operation of a component.

event - something that occurs as a result of a component's interaction with the user or with Windows.

event handler - a method invoked in your application in response to an event.

C++ Builder workspace

From Designer - enables me to create forms.

Code Editor - where I type the code when I write my program.

To get a console in C++Builder 6

File->Other...

Select the 'Console Wizard' under the 'New' tab.

To find out where something is declared. Select it and then press 'F1' key.

Manipulators - used to control how streams are handled.

Created by first console application.

Borland C++ Builder 3 in 21 Days

I have borrowed this book of Borland builder.

I also noticed this website: http://www.visualcomponentlibrary.com/bcb/

The web site doesn't seem to be giving me a good overall view. The book is a little old but I am hoping it will do the trick.

Tuesday, December 5, 2006

Borland Database Engine (BDE)




I have found a page the lets me add the elements to a canvas.

I have added a TTable.

Having to log into the local SQL Server, but it doesn't seem to really be there. It is telling me to use SQLDriverConnect.

Where do I find SQLDriverConnect?

I have somehow lost my form window.

Let take a look at the existing code.

What is a '.bpg' file? A project group.

What is a '.bpi' file?

Online Help

Looks like some nice database tutorials.

I cannot do the "Creating a CLZ database application" because I have a 'Personal' edition of Borland and I may not have Interbase.

This 'Help' is not too helpful. It might be if I already new, but what I am looking for is a true tutorial, which they don't seem to have.

How to Start?

How is the best way to start?

Should I locate a nice web page that would walk me through the process or should I start in the online help?

Which Version


We are currently using the 6.0 version for 2002.