Database, Sessions and Scattering

Posted on 2002-04-10
Last Modified: 2013-11-23
unit hello;


  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  StdCtrls, DB, DBTables;

  TForm1 = class(TForm)
    Query : TQuery;
    DataSource : TDataSource;
    Database : TDatabase;
    Edit1: TEdit;
    Edit2: TEdit;
    Edit3: TEdit;
    Edit4: TEdit;
    Edit5: TEdit;
    Edit7: TEdit;
    Edit8: TEdit;
    Edit9: TEdit;
    Edit10: TEdit;
    Edit11: TEdit;
    Button1: TButton;
    procedure Button1Click(Sender: TObject);
    { Private declarations }
    { Public declarations }

  Form1: TForm1;


{$R *.DFM}
procedure TForm1.Button1Click(Sender: TObject);
  procedure CreateQuery;
      QueryName = 'select employeeid\n' +
                   'from details\n';

           Database.DatabaseName := 'Peracc.mdb';
           Query.DatabaseName := 'Peracc.mdb';
           DataSource.Dataset := Query;

           {   edit1.ext :=;}


With the above code snippnet, I'd like to raise 3 questions...

part 1.   Database.DatabaseName := 'Peracc.mdb';
          Query.DatabaseName := 'Peracc.mdb';

          Are these statements workable?

part 2.  How do I deal with the 'session' thing?

part 3. How do I scatter the variable 'employeeid' into edit1 (A textbox in C++ sense)?

severely urgent!
Question by:luckie
  • 9
  • 6
  • 3
LVL 27

Expert Comment

ID: 6930922
part1 := 'myDB';
Database.DatabaseName := the aliasname you've defined in the bde;

Query.DatabaseName := the aliasname you've defined in the bde;

or if you want to bundle the tdatasets to the tdatabase

Query.DatabaseName := 'myDB';

what will you deal with this?
there is automatically created a tsession-object named session, all datasets are bound to this session-object, until you assign another

edit1.text := query1.fieldbyname('fieldName').asstring;

for the future, one question in a question

meikl ;-)

LVL 27

Expert Comment

ID: 6930930
\n is unusual in pascal and may cause an error

Author Comment

ID: 6930981
still no clue...
Could u fix the code snippet for me?
I don't think it's too difficult for an expert like you :)
please don't tell me off.... another :)

Author Comment

ID: 6930986
I was intending to ask three questions in one... but its too urgent as can be... need to go to interview tomorrow with the code... so bear with me tho...

Author Comment

ID: 6930987
I meant wasn't intending

Author Comment

ID: 6931006
what's the 'aliasname' mean? need to bring the code along tomorrow... so need quick response... thanks
LVL 27

Expert Comment

ID: 6931132
guessing you've never done
a db-app with delphi, right?

well first you must tell me
how you want to connect to the database,
odbc, ado, bde-native, other?
(is it ms-access, and is it a must?)

depending on this you must configure the bde,
except you use ado. do you have expirience with the bde?

another-question, there are dataaware-controls,
which you can use instead of tedit, will you use dataaware-controls?

next question: you can do many assignments at designtime,
will you do the assignments at designtime or runtime?

depending on your answers,
i will try to give you a
step by step instruction

meikl ;-)
LVL 44

Expert Comment

ID: 6931171
Yeah agree with meikl. Need lots more information about which connection method your implemetning and which database you are using. How you connect to the database determines a lot on how the code would be written. And which database you use can affect the syntax the SQL statement.

The Crazy One

Author Comment

ID: 6931239
still trying... well... I'm using Visual Foxpro database...
I have sort of been setting up something... called the data controls... I've got 3 files... they are personnel1.dbc and per1.dbf and holiday.dbf and that's it
I have been thinking that it would be good enough to set up the properties of the controls in order to control the database ... I've encountered one problem finally... called invalid configuration parameter Alias :  personnel1 when I touched on the datafield property any ideas how to get around this...
Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.


Author Comment

ID: 6931242
Yes, you were right... Zero Experience at alllllllllllllll
LVL 27

Accepted Solution

kretzschmar earned 100 total points
ID: 6931287
well, ok foxpro,

for foxpro files you must setup an alias in the bde based on the dbase-driver

-go into your systempreferences and start the bde-admin,
-go to tab databases
-menu file|new->select dbase from the dropdownlist
-a new branch appears in the tree
-rename the default-name as you want (thats the alias name)
-on the right side select the directory where your tables
reside and adjust the dbase level (see bde-help for foxpro configuration)
-save the changes

test the configuration
-press the plus-sign left on your new created alias
-if all ok, a green frame appears around the alias icon, otherwise an errormessage comes up, in this case reedit your entries

close the bde-admin, start delphi, start a new application

-drop a ttable on the form
-select on the databasename your alias
-select on tablename a table you want
-set the active-property to true
-drop a datasource on the form
-select as dataset your ttable
-drop a tdbgrid on your form
-select as datasource your tdatasource

run your app
(thats the simplest way,
to setup a simple database-app,
where you can edit, insert, delete records from one table)

no line code is used

meikl ;-)
LVL 27

Expert Comment

ID: 6931295
crazy, did i missed something?
(because that was just from head)
LVL 44

Expert Comment

ID: 6932517
Phew it looks like you got it all meikl. I am impressed with your head. LOL :>)

Author Comment

ID: 6933838
don't worry. Just stuffed it... the interviewer asked me what BOM was... who would know what the hell BOM was... anyway, I could only satify one of the three questions he asked of me... Thanks for helping anyway...
LVL 27

Expert Comment

ID: 6933879
glad to helped you ;-)
but what the hell is BOM?
LVL 44

Expert Comment

ID: 6934109
BOM := 'Big Explosion, like in kaboom!!!!'; hehehehehe

Author Comment

ID: 6934311
According to their brains, BOM is 'Bill of Manufacturing'. It's a humanly maintained system that directs the flow of raw materials to finished goods. Bye

Author Comment

ID: 6934318
sorry, not raw materials, but parts...

Featured Post

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

24 Experts available now in Live!

Get 1:1 Help Now