[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

Database, Sessions and Scattering

Posted on 2002-04-10
18
Medium Priority
?
288 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

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 400 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

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

Question has a verified solution.

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

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…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …
Suggested Courses

650 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