Solved

Database, Sessions and Scattering

Posted on 2002-04-10
18
281 Views
Last Modified: 2013-11-23
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
Comment
Question by:luckie
  • 9
  • 6
  • 3
18 Comments
 
LVL 27

Expert Comment

by:kretzschmar
ID: 6930922
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
 
LVL 27

Expert Comment

by:kretzschmar
ID: 6930930
appendix
\n is unusual in pascal and may cause an error
0
 

Author Comment

by:luckie
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 :)
0
PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

 

Author Comment

by:luckie
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...
0
 

Author Comment

by:luckie
ID: 6930987
I meant wasn't intending
0
 

Author Comment

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

Expert Comment

by:kretzschmar
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 ;-)
0
 
LVL 44

Expert Comment

by:CrazyOne
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
0
 

Author Comment

by:luckie
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...
0
 

Author Comment

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

Accepted Solution

by:
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 ;-)
0
 
LVL 27

Expert Comment

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

Expert Comment

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

Author Comment

by:luckie
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...
0
 
LVL 27

Expert Comment

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

Expert Comment

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

Author Comment

by:luckie
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
0
 

Author Comment

by:luckie
ID: 6934318
sorry, not raw materials, but parts...
0

Featured Post

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

810 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