• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 295
  • Last Modified:

Database, Sessions and Scattering

unit hello;

interface

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

type
  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
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

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

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

           {   edit1.ext := DataSource.Dataset.company.text;}
  end;
begin

end;
end.


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!
Thanks
Jacky
0
luckie
Asked:
luckie
  • 9
  • 6
  • 3
1 Solution
 
kretzschmarCommented:
part1

database.name := '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';

part2
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

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


for the future, one question in a question

meikl ;-)



0
 
kretzschmarCommented:
appendix
\n is unusual in pascal and may cause an error
0
 
luckieAuthor Commented:
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 :)
0
Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
luckieAuthor Commented:
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...
0
 
luckieAuthor Commented:
I meant wasn't intending
0
 
luckieAuthor Commented:
what's the 'aliasname' mean? need to bring the code along tomorrow... so need quick response... thanks
0
 
kretzschmarCommented:
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 ;-)
0
 
CrazyOneCommented:
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
0
 
luckieAuthor Commented:
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...
0
 
luckieAuthor Commented:
Yes, you were right... Zero Experience at alllllllllllllll
0
 
kretzschmarCommented:
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 ;-)
0
 
kretzschmarCommented:
crazy, did i missed something?
(because that was just from head)
0
 
CrazyOneCommented:
Phew it looks like you got it all meikl. I am impressed with your head. LOL :>)
0
 
luckieAuthor Commented:
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...
0
 
kretzschmarCommented:
glad to helped you ;-)
but what the hell is BOM?
0
 
CrazyOneCommented:
BOM := 'Big Explosion, like in kaboom!!!!'; hehehehehe
0
 
luckieAuthor Commented:
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
0
 
luckieAuthor Commented:
sorry, not raw materials, but parts...
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

  • 9
  • 6
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now