Click here to Skip to main content
15,889,335 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello.

I have a "simple" question.

NOTE - This is needed for Delphi actually but I it doesn't matter either is it a C# or Delphi ButtonClick. Just need the code. But if I get an answer, I might switch to C# since the application is still at beginning.

This is my first try at database programming. Anyway I need this urgently.
I am building an application. I have everything ready, I just need the following. How to:

When I press a button, it reads a Text or Numbers from mdb/accdb database?

Form has many buttons and I need to:

1. Press button 1: 3 dbEdit fields change
2. Press button 2: same dbEdit fields change with different values from mdb file.
3, Same for other buttons. Just read values from proper ID.

I just don't know how to access the values in the mdb file. I tried everything possible I could find on the net. Nothing with BUTTON. all go with Grids and similar.

And also if any help:

Database Name: Enigma.mdb
Table: EnigmaTable
Field1: ID
Field2: EngineLevel
Field3: EngineBase
Field4: EngineName

C#
ADOConnection = EnigmaConnection
TADODataSource = dsEnigma
TADOTable = tblEnigma

If you need more details, I'll provide.

Thanks in advance.
Posted
Updated 5-Nov-11 23:35pm
v2

1 solution

If you want help with Delphi then :
Try to work with ADO components , So
Add a ADOConnection after configuring it(setting its connection string) ,set its Active property to true then
Add a ADOTable and set its connection and table and set its Active to True
And then add a DataSource and set its DataSet to ADOTable
Then drop a DataGrid and set its DataSource to the previously added datasource

If you want to work with individual rows in table try to observe ADOTable methods.
Also consider using ADOQuery and ADOCommand.

Good Luck

After you comment :
So if you did these things start writing your SQLs in ADOQuery 's SQL :
SQL
select * from EnigmaTable where ID=:id 

put a ":" behind every name that you want to become a parameter.
and set the parameters values before executing the ADOQuery datasets.
After running the SQL you can access their values by something like this :
Delphi
Query1.FieldByName("EngineName").AsString
 
Share this answer
 
v3
Comments
obi.bin 6-Nov-11 7:35am    
I know how to do all that. Please read the thread again. I have set up everything for DB access. Just need a a way to read values from access database.

You can write it in C#. I can translate.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900