Subject | Dynamic TIBDatabase |
---|---|
Author | scotty_ncc1701_2003 |
Post date | 2005-04-06T16:39Z |
I know how to put IBDatabase, IBTransaction, etc on a form and use
them. However, I would like to create these things via code, and not
by dropping the items on a form (or in a datamodule). While testing
it out, I'm doing something wrong. here is part of the code.
---------------->Begin partial code quote
#include <vcl.h>
#include <Classes.hpp>
#include <Controls.hpp>
#include <StdCtrls.hpp>
#include <Forms.hpp>
#include <Db.hpp>
#include <IBCustomDataSet.hpp>
#include <IBDatabase.hpp>
#include <IBTable.hpp>
#pragma hdrstop
#include "Unit1.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm1 *Form1;
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)
{
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button1Click(TObject *Sender)
{
TDataSource *DataSource1;
TIBTable *IBTable1;
TIBDatabase *IBDatabase1;
TIBTransaction *IBTransaction1;
IBDatabase1->DatabaseName = "DEMO.GDB"; // access violation
IBDatabase1->DefaultTransaction = IBTransaction1;
IBDatabase1->Connected = true;
.
.
.
.
.
---------------->End partial code quote
It errors out at the DatabaseName line above. What am I doing wrong?
them. However, I would like to create these things via code, and not
by dropping the items on a form (or in a datamodule). While testing
it out, I'm doing something wrong. here is part of the code.
---------------->Begin partial code quote
#include <vcl.h>
#include <Classes.hpp>
#include <Controls.hpp>
#include <StdCtrls.hpp>
#include <Forms.hpp>
#include <Db.hpp>
#include <IBCustomDataSet.hpp>
#include <IBDatabase.hpp>
#include <IBTable.hpp>
#pragma hdrstop
#include "Unit1.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm1 *Form1;
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)
{
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button1Click(TObject *Sender)
{
TDataSource *DataSource1;
TIBTable *IBTable1;
TIBDatabase *IBDatabase1;
TIBTransaction *IBTransaction1;
IBDatabase1->DatabaseName = "DEMO.GDB"; // access violation
IBDatabase1->DefaultTransaction = IBTransaction1;
IBDatabase1->Connected = true;
.
.
.
.
.
---------------->End partial code quote
It errors out at the DatabaseName line above. What am I doing wrong?