Subject | RE: [firebird-support] Dynamic TIBDatabase |
---|---|
Author | Nathan Jobe |
Post date | 2005-04-06T16:53:35Z |
Try using the "new" call before you do anything with those uninitialized
pointers you got there. Don't forget to destroy your objects when your done
with them. This usually happens in FormClose
-----Original Message-----
From: scotty_ncc1701_2003 [mailto:scotty_ncc1701_2003@...]
Sent: Wednesday, April 06, 2005 11:39 AM
To: firebird-support@yahoogroups.com
Subject: [firebird-support] Dynamic TIBDatabase
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?
Yahoo! Groups Links
pointers you got there. Don't forget to destroy your objects when your done
with them. This usually happens in FormClose
-----Original Message-----
From: scotty_ncc1701_2003 [mailto:scotty_ncc1701_2003@...]
Sent: Wednesday, April 06, 2005 11:39 AM
To: firebird-support@yahoogroups.com
Subject: [firebird-support] Dynamic TIBDatabase
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?
Yahoo! Groups Links