This is old stuff! Is related to delphi 5.0 and interbase 1.6.
I'm trying to open a DB connection via code. But this code is related to enabling the connection, all the components were added using delphi drag-drop User Interface: DataSource1, TForm1, DBGrid, DBNavigator etc..
procedure TDataModule2.DataModuleCreate(Sender: TObject);
begin
database.DatabaseName:='C:\MyDatabase.GDB';
database.Connected := true;
database.Open;
IBTransaction.Active := true;
myTable.Open;
end;
I have a TForm with DBGrid and DBNavigator component. I also have a TIBQuery (that DataSource1 is associated to) with this code on the SQLStrings:
SELECT * FROM NEW_TABLE
On the Form I have this code to enable DBNavigator and DBGrid to show the DB Values. The DB is very simple is just a table: NEW_TABLE with a NEW_VALUE of VARCHAR type
procedure 开发者_运维知识库TForm1.FormCreate(Sender: TObject);
begin
DataSource1.DataSet.Open;
// This will call the query associated to this DataSource1 the tibQuery1 to call
// SELECT * FROM NEW_TABLE, but the message below appears: IBClientError...
end;
The message appears: IBClientError with message 'Database not assigned'
OBS1: If I connect the components by hand on delphi user interface, the connection with the DB is established.
You have to assign the Database
property of your query, something like:
IBQuery1.Database := MyDatabase;
精彩评论