Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

Need help with simple database

I need to create a simple employee database in a Paradox database. Iv'e made the form, but now I seem to be stuck.
Could somebody give me a hand, and plz tell me what I should post to show you what Iv'e done, coz I don't think I can post the form, right?

Thank you
«1

Comments

  • gmadisongmadison Posts: 13Member
    : I need to create a simple employee database in a Paradox database. Iv'e made the form, but now I seem to be stuck.
    : Could somebody give me a hand, and plz tell me what I should post to show you what Iv'e done, coz I don't think I can post the form, right?
    :
    : Thank you
    :
    Here are the steps I use:

    1. Create a director where you want your program and database to reside. Example folder: dbdemo

    2. Create the data base elements by opening the database desktop. Click on File|New|Table. Keep the default Table Type of Paradox 7 and click OK.

    3. Enter each field you want in the database along with the type, size, and key. The key is used to determine if a particular record is being duplicated. To ensure no records are duplicated, set the key in the patients record number (this number is unique for each patient). For the example, we are going to have the following fields in the patients database:

    Pt Name
    Pt record number
    Pt Sex
    Pt diagnosis
    Referring Physician

    Type is either A for alphanumeric, N for number, D for Date, etc.

    4. Select Table properties and change the selection to Secondary Indexes. Click on Define. Hilite Name and pres the -> key to move it to the right side window. Click on OK and enter the name NameInd.

    5. Click on Save As and enter the name patient1. Change the director to the same one you created for this (dbdemo). Change the Alias to None and save.

    6. Close the Database Desktop. The patient database is now created and can be used.

    7. Open the Delphi Compiler. Click on File|Save All. Change the directory to the one created for this example (dbdemo) and change Unit1.pas to read ptdb_s.pas. Change Project1.dpr to read ptdb.dpr.

    8. Under Data Access click on the Table icon and drop it somewhere on the form.

    9. Under the Object Inspector, type in C:dbdemo for the DatabaseName property.

    10. Click the down arrow button for the TableName and select patient1.db.

    11. Change the Name property to Ptdb1.

    12. Change the Active property to True.

    13. Under Data Access click on the Data Source icon and drop it somewhere on the form.

    14. Change the DataSet property to ptdb1.

    15. Change the Name property to ds_ptdb1.

    16. Under Data Controls click on the DBGrid icon and drop it somewhere on the form.

    17. Change the DataSource property to ds_ptdb1.

    18. Start using the database

  • Rodimus PrimeRodimus Prime Posts: 51Member
    : : I need to create a simple employee database in a Paradox database. Iv'e made the form, but now I seem to be stuck.
    : : Could somebody give me a hand, and plz tell me what I should post to show you what Iv'e done, coz I don't think I can post the form, right?
    : :
    : : Thank you
    : :
    : Here are the steps I use:
    :
    : 1. Create a director where you want your program and database to reside. Example folder: dbdemo
    :
    : 2. Create the data base elements by opening the database desktop. Click on File|New|Table. Keep the default Table Type of Paradox 7 and click OK.
    :
    : 3. Enter each field you want in the database along with the type, size, and key. The key is used to determine if a particular record is being duplicated. To ensure no records are duplicated, set the key in the patients record number (this number is unique for each patient). For the example, we are going to have the following fields in the patients database:
    :
    : Pt Name
    : Pt record number
    : Pt Sex
    : Pt diagnosis
    : Referring Physician
    :
    : Type is either A for alphanumeric, N for number, D for Date, etc.
    :
    : 4. Select Table properties and change the selection to Secondary Indexes. Click on Define. Hilite Name and pres the -> key to move it to the right side window. Click on OK and enter the name NameInd.
    :
    : 5. Click on Save As and enter the name patient1. Change the director to the same one you created for this (dbdemo). Change the Alias to None and save.
    :
    : 6. Close the Database Desktop. The patient database is now created and can be used.
    :
    : 7. Open the Delphi Compiler. Click on File|Save All. Change the directory to the one created for this example (dbdemo) and change Unit1.pas to read ptdb_s.pas. Change Project1.dpr to read ptdb.dpr.
    :
    : 8. Under Data Access click on the Table icon and drop it somewhere on the form.
    :
    : 9. Under the Object Inspector, type in C:dbdemo for the DatabaseName property.
    :
    : 10. Click the down arrow button for the TableName and select patient1.db.
    :
    : 11. Change the Name property to Ptdb1.
    :
    : 12. Change the Active property to True.
    :
    : 13. Under Data Access click on the Data Source icon and drop it somewhere on the form.
    :
    : 14. Change the DataSet property to ptdb1.
    :
    : 15. Change the Name property to ds_ptdb1.
    :
    : 16. Under Data Controls click on the DBGrid icon and drop it somewhere on the form.
    :
    : 17. Change the DataSource property to ds_ptdb1.
    :
    : 18. Start using the database
    :
    :

    Which files do I need to copy if I wish to take the project home with me?

  • Rodimus PrimeRodimus Prime Posts: 51Member
    : : I need to create a simple employee database in a Paradox database. Iv'e made the form, but now I seem to be stuck.
    : : Could somebody give me a hand, and plz tell me what I should post to show you what Iv'e done, coz I don't think I can post the form, right?
    : :
    : : Thank you
    : :
    : Here are the steps I use:
    :
    : 1. Create a director where you want your program and database to reside. Example folder: dbdemo
    :
    : 2. Create the data base elements by opening the database desktop. Click on File|New|Table. Keep the default Table Type of Paradox 7 and click OK.
    :
    : 3. Enter each field you want in the database along with the type, size, and key. The key is used to determine if a particular record is being duplicated. To ensure no records are duplicated, set the key in the patients record number (this number is unique for each patient). For the example, we are going to have the following fields in the patients database:
    :
    : Pt Name
    : Pt record number
    : Pt Sex
    : Pt diagnosis
    : Referring Physician
    :
    : Type is either A for alphanumeric, N for number, D for Date, etc.
    :
    : 4. Select Table properties and change the selection to Secondary Indexes. Click on Define. Hilite Name and pres the -> key to move it to the right side window. Click on OK and enter the name NameInd.
    :
    : 5. Click on Save As and enter the name patient1. Change the director to the same one you created for this (dbdemo). Change the Alias to None and save.
    :
    : 6. Close the Database Desktop. The patient database is now created and can be used.
    :
    : 7. Open the Delphi Compiler. Click on File|Save All. Change the directory to the one created for this example (dbdemo) and change Unit1.pas to read ptdb_s.pas. Change Project1.dpr to read ptdb.dpr.
    :
    : 8. Under Data Access click on the Table icon and drop it somewhere on the form.
    :
    : 9. Under the Object Inspector, type in C:dbdemo for the DatabaseName property.
    :
    : 10. Click the down arrow button for the TableName and select patient1.db.
    :
    : 11. Change the Name property to Ptdb1.
    :
    : 12. Change the Active property to True.
    :
    : 13. Under Data Access click on the Data Source icon and drop it somewhere on the form.
    :
    : 14. Change the DataSet property to ptdb1.
    :
    : 15. Change the Name property to ds_ptdb1.
    :
    : 16. Under Data Controls click on the DBGrid icon and drop it somewhere on the form.
    :
    : 17. Change the DataSource property to ds_ptdb1.
    :
    : 18. Start using the database
    :
    :

    How can I enter data into the database???
  • gmadisongmadison Posts: 13Member
    To transport the database to another computer you will need the database files (e.g., if your database name is demo.db, you will need all the files of demo.*). You will also need the database engine on other computers. These are a lot of Borland DBE files. The easiest way to get them on other computers is to create an install disk and include the database engine. I can give you example code to enter data into the database but it may be a few days.
    GM
  • Rodimus PrimeRodimus Prime Posts: 51Member
    : To transport the database to another computer you will need the database files (e.g., if your database name is demo.db, you will need all the files of demo.*). You will also need the database engine on other computers. These are a lot of Borland DBE files. The easiest way to get them on other computers is to create an install disk and include the database engine. I can give you example code to enter data into the database but it may be a few days.
    : GM
    :

    That would be great, but please hurry if you can, coz I'm kinda stuck.
    Thank you
  • gmadisongmadison Posts: 13Member
    1 Create the database using the Database Desktop. I used two fields for this example called Field1 and Field2

    2. Start your delphi and drop a Table on the form from the DataAccess tab.

    3. Under the object inspector, set the Database Name property to the directory where your database resides. In my example, I entered c:demo

    4. For the Table Name property, click the down arrow button and select the database name (in my example, the name of the database was demodb.db

    5. Set the Active property to True

    6. Drop a DataSource onto the form from the DataAccess tab.

    7. From the object inspector, click the down arrow button for the Dataset and select 'Table1'

    8. Under the DataContol tab, drop a DBGrid onto the form. From the object inspector, click the down arrow button for the DataSource and select 'DataSource1'. At this point, the DBGrid should show 2 fields, Field1 and Field2 in the header.

    9. Under the Form1 object inspector, click on the Events tab and under OnActivate, type in the code: Table1.Insert;

    10. Drop a standard button on the form and enter the code for the button of: Table1.Post;

    11. Run the program and click on the first database field and enter your data. Click tab to move to the second field and enter your data. When you click tab again, you move to a new row in the data base and back to field1. Keep doing this until your data is in then click your button to post the changes into the database.

    This should get you started. Once you're comfortable with this, you can get real creative on data entry, updating, sorting, etc., using DBEdits. Good luck.

    GM
  • Rodimus PrimeRodimus Prime Posts: 51Member
    [b][red]This message was edited by Rodimus Prime at 2004-6-21 0:35:25[/red][/b][hr]
    : 1 Create the database using the Database Desktop. I used two fields for this example called Field1 and Field2
    :
    : 2. Start your delphi and drop a Table on the form from the DataAccess tab.
    :
    : 3. Under the object inspector, set the Database Name property to the directory where your database resides. In my example, I entered c:demo
    :
    : 4. For the Table Name property, click the down arrow button and select the database name (in my example, the name of the database was demodb.db
    :
    : 5. Set the Active property to True
    :
    : 6. Drop a DataSource onto the form from the DataAccess tab.
    :
    : 7. From the object inspector, click the down arrow button for the Dataset and select 'Table1'
    :
    : 8. Under the DataContol tab, drop a DBGrid onto the form. From the object inspector, click the down arrow button for the DataSource and select 'DataSource1'. At this point, the DBGrid should show 2 fields, Field1 and Field2 in the header.
    :
    : 9. Under the Form1 object inspector, click on the Events tab and under OnActivate, type in the code: Table1.Insert;
    :
    : 10. Drop a standard button on the form and enter the code for the button of: Table1.Post;
    :
    : 11. Run the program and click on the first database field and enter your data. Click tab to move to the second field and enter your data. When you click tab again, you move to a new row in the data base and back to field1. Keep doing this until your data is in then click your button to post the changes into the database.
    :
    : This should get you started. Once you're comfortable with this, you can get real creative on data entry, updating, sorting, etc., using DBEdits. Good luck.
    :
    : GM
    :

    Hi, thanks for your help so far, can I prompt you again if I need further help?
    coz there is this file called PDOXUSRS.NET that has been created. Must I also save this file or can I delete it?

    And I don't understand the first step. I thought I already created the database? and how do I go about creating those fields???
    thanks,
  • gmadisongmadison Posts: 13Member

    I actually did take you back to the beginning in the first steps. If you've already used the Database Desktop and created the fields, then you would begin the building of the database in the delphi code at step #2. I'm not sure what the .NET file is. What delphi version are you using? The steps I've given work for Delphi Ver 3 and I think work for Delphi Ver 7 however I've just purchased 7 and haven't created a database from scratch with it yet. All my code and databases written in Ver 3 work fine under 7, so there can't be too much difference.

    Taking a step back, have you created the fields you want in the database using the Database Desktop yet? If not, this is the first thing you need. Keep in mind that the Database Desktop is a program outside of Delphi. If you have your paradox table created, start Delphi and begin with the code entry at step 2. If you want to post your e-mail, I could send you a sample program and related files.
    GM


  • Rodimus PrimeRodimus Prime Posts: 51Member
    [b][red]This message was edited by Rodimus Prime at 2004-6-22 0:41:46[/red][/b][hr]
    [b][red]This message was edited by Rodimus Prime at 2004-6-22 0:28:31[/red][/b][hr]
    [b][red]This message was edited by Rodimus Prime at 2004-6-21 23:33:24[/red][/b][hr]
    [b][red]This message was edited by Rodimus Prime at 2004-6-21 23:31:53[/red][/b][hr]
    :
    : I actually did take you back to the beginning in the first steps. If you've already used the Database Desktop and created the fields, then you would begin the building of the database in the delphi code at step #2. I'm not sure what the .NET file is. What delphi version are you using? The steps I've given work for Delphi Ver 3 and I think work for Delphi Ver 7 however I've just purchased 7 and haven't created a database from scratch with it yet. All my code and databases written in Ver 3 work fine under 7, so there can't be too much difference.
    :
    : Taking a step back, have you created the fields you want in the database using the Database Desktop yet? If not, this is the first thing you need. Keep in mind that the Database Desktop is a program outside of Delphi. If you have your paradox table created, start Delphi and begin with the code entry at step 2. If you want to post your e-mail, I could send you a sample program and related files.
    : GM
    :
    :
    :

    Hi thanks,
    Going back to Database Desktop I added these fields - Employee Number, Employee Last Name, Employee First Name, Department, Phone Extension Number, Street Address, Suburb Address, City Address, and Manager ID.

    I set the Employee Number to the primary key, and used that secondary indexes thing for Employee Last Name.
    In Delphi, when I dropped the DBGrid onto the form I see all the fields apart from the Employee Number and Employee Last Name fields. Should these two fields indeed not be showing on the DBGrid?

    EDIT - On a closer look, those two fields are on the DBGrid afterall.


    I work with delphi 6 at school and 7 at home. I haven't transferred files from school to home or vica versa yet. I think I will copy all the files belonging to the project should I need to work on it from different locations, is that ok?

    my e-mail address is Glvtn_06@hotmail.com

    EDIT - sorry for the editing, but new question keep popping up as I progress, I hope that's ok
    In tut 2 step 9 I must type in Table1.insert, must I type in employee1.db - which is my TableName property or Empdb1 - which is my Name property.

    I also don't fully understand step 10 of tut 2, what code must I enter for the button?

    EDIT - One last edit, I want to make a little bit more clear to you what I'm trying to do here.
    So you know which fields I need, furthermore, the program should allow the user to add a new employee, find details about an employee from the emp number, and the program has to be able to print a list of all the employees currently stored in the database. The list doesn't need to be sorted initially. After I get it all working, maybe I'll sort it too.
    Oh, and is there a way I can check for errors when for example the user tries to enter a letter for the emp number?

    Sorry bout all the edits, hopefully your'e not sick of me yet hehe

    Cheers










  • gmadisongmadison Posts: 13Member
    I'll be in touch via e-mail with a program and source code for a typical database that lets the user add/delete/modify info within the database. I'll use Delphi Ver3 for the code since I know a program written in D3 works fine in D7 (and should therefore work fine in D6). I'm not sure if it would work in reverse order from D7 to D6.
    GM
«1
Sign In or Register to comment.