Delphi 7 with ADO DBGrid, entering contents of record into variables. [Edit]

Hi there,

For my A-Level computing coursework I'm using a Delphi front-end on an MS Access Database, to store information on customers and create an invoice for them, by calculating data within the database.

Basically my problem is this:

Is there a way that the user can select a specific record within a DBGrid component, and then have a procedure that will assign the contents of each field for this specific record into a separate variable?

E.g. the Record goes like

Name: John Smith
Date of Birth: 04/09/2005,

and when that record is selected, the data contained within name will be assigned to a relevant delphi variable entitled 'name' etc

Also,there will be variables of different types, including integers, strings and booleans. Can I make it account for this as well?

Thanks,

Edited by: James Harland on Feb 6, 2009 3:45 AM

Edited by: James Harland on Feb 6, 2009 3:46 AM
0
James
2/6/2009 11:46:54 AM
embarcadero.delphi.ado 597 articles. 1 followers. Follow

2 Replies
3185 Views

Similar Articles

[PageSpeed] 20
Get it on Google Play
Get it on Apple App Store

I would get the data from the ado query instead of getting the data from the dbgrid.

sVariableName := qryName.FieldByName('').AsString (or asInteger...whatever your data type)

I use 3rd party DBGrids that make it easy for me to detect when the selected row has changed...but you could get this from the ado query.  Take a look at the query's AfterScroll method.  Note:  AfterScroll fires when the state of the query changes, for example when switching to Insert or Edit mode.  You could check to make sure the query is in browse mode and if so assign the values to your variables:

if qryName.State = dsBrowse then

I hope this helps
0
Carl
2/6/2009 1:19:26 PM
Create an AfterScroll event handler for the ADODataSet that
supplies data to to the grid. In the event handler use

AVariable := ADODataSet1.FieldByName('SomeField').AsString;

Replace AsString with the correct property for the data
type of the variable (AsInteger, AsFloat, etc.).

-- 
Bill Todd (TeamB)
1
Bill
2/6/2009 2:39:07 PM
Reply:

Similar Artilces:

Convert Delphi 5 ADO App to Delphi 2007 ADO.NET
I have an appliction tha that is writen in Delphi 5 with ADOConnetion, ADOTable, and ADOQuery components. I need to upgrade to Delphi 2007 and use ADO.NET. I have the program building in with Delphi 2007. Is there anything I need to do to convert the ADO to ADO.NET? > I need to upgrade to Delphi 2007 and use ADO.NET. Why ? -- With best regards, Dmitry Arefiev AnyDAC (www.anydac.com) - Oracle, MS SQL Server, IBM DB2, MySQL, Firebird, Interbase, PostgreSQL, Sybase ASA, SQLite, MS Access, DBX, ODBC, InMem - universal high-speed native data access engine Reasons for ...

How to create a Delphi 7 ADO "LIVE" (auto update) query to SQL Server [Edit]
How to create a Delphi 7 ADO "LIVE" query (one SQL Server table only) that once a table field is edited - the underlying query results are updated. Kind of like the "LIVE" query concept from the BDE etc. Below is the ADO query that I am using and it generally *seems* to work well where once a field is edited (via TADOQuery.Edit, .Post etc), the query result are also changed. I think it is true that after an edit the change is always visible in the same program using the same query object. {code}procedure ExecuteQryTable( Connection: TADOConnection; Qry: TADOQuer...

Convert Delphi 7 to Delphi 2009 [Edit]
Hi! Please, I have a code done in Delphi 7... Now I want to convert Delphi 7 to Delphi 2009 but I'm having problems when compile the code. Error message: +[DCC Fatal Error] Far.dpr(9): F2063 Could not compile used unit 'System.pas'+ Please can somebody help me? Source Download (349KB): http://rapidshare.com/files/256191328/FileManager.rar.html Mirror Source Download: http://www.megaupload.com/?d=12GYLPT0 Password: delphi Thank u so much! (sorry for my bad english, it is not my native language) Edited by: loquax loquax on Jul 15, 2009 12:24 PM Sorry, bu...

Delphi 6 to Delphi 2010 upgrade and ADO
We have an application written in Delphi 6 Professional that uses ADO to access databases servers that may be on other PCs in our network. We want to move to Delphi 2010 but can't decide if we need Professional or Enterprise. 2010 Pro has dbGO - will this give us the same functionality as the ADO components we use in Delphi 6 Pro? Thanks, Keith > 2010 Pro has dbGO - will this give us the same functionality as the > ADO components we use in Delphi 6 Pro? Yes. > {quote:title=Joachim Uersfeld wrote:}{quote} > > 2010 Pro has dbGO - will this give us the same func...

ASA7 ADO & Delphi ADO ?? Anyone is using it?
Any comments? Is it working? Any Problems? Thanks Hi, PR <noemail@no.com> schrieb in im Newsbeitrag: BoTThJaq$GA.89@forums.sybase.com... > Any comments? Is it working? Any Problems? I tried to connect to ASA7 via the new OLE DB - Provider and ADOExpress from Delphi 5.01. No chance. Only the error message 'Invalid Enum Value'. About the new provider I haven't heard anything good until now... Regards Frank Frank, I've experienced the same problem with the ASA 7 OLEDB Provider. I'm not sure if this is a bug in the AsaProvider or Delp...

Delphi 7 to Delphi XE: TBlobField to XML [Edit]
Hi, I'm migrating a Delphi7 application to Delphi XE. I'm using a TClientDataSet to communicate, by using a XML frame, with my server. In this TClientDataSet I'm using a TBlobField which is an array of 384 byte. The blobField is allocate by a code like this : {code} myStream : TStream; myStream := aClientDataSet.CreateBlobStream(myBlobField, bmwrite); vResult := myStream.Write(ArrayOf384Byte[0], length(ArrayOf384Byte)); //vResult = 384 => GooD ! (...) {code} For communicate with the server, we have to decode the Blobfield in XML before to sending it. We have...

Code works in Delphi 7 but not in Delphi 2010 [Edit]
hello, i have a procedure that open's a file by passing the file name as the parameter to the executable. something like this {code} C : \ P r o g r a m F i l e s \ Da c k e r \ D r a c k e r . e x e " G : \ D E l p h i 7 \ D e l p h i 7 A p p _ l o g . t " {code} The source code is {code} procedure OpenFileWithExe var hReg: HKEY; Ret: Longint; RegDataType, RegDataSize: DWORD; CmdLine: array [0..560] of Char; Len: Integer; SInfo: TStartupInfo; PInfo: TProcessInformation; begin Ret := windows.RegOpenKeyEx(HKEY_CURRENT_USER, ...

How to sort records in Delphi DBGrid [Edit]
I need to alphabetically sort records in the TDBGrid at run-time I don't want to sort records from the Table or Dataset because that is my main sort index. I can't seem to work this out can someone help please? I am using Delphi 7 it really works for me. Edited by: unit4 P on Aug 11, 2012 3:10 PM Edited by: unit4 P on Aug 11, 2012 4:38 PM On 12/08/2012 9:38 AM, unit4 P wrote: > I need to alphabetically sort records in the TDBGrid at run-time > I don't want to sort records from the Table or Dataset because that is my main sort index. > > I can't se...

Delphi 2007 to Delphi 7
I've written a class in Delphi 2007 that is not supported in Delphi 7. What would be the best way to achive what I've done in Delphi 2007 in Delphi 7? Thanks, Tom type BondConstants = class { Bond Types } type BondType = record const TREASURY = 3; AGENCY = 0; CORP = 1; MUNI = 2; SBA = 5; MBS = 4; CMO = 6; end; { Day Count Methods } type DayCount = record const ACTUAL_360 = 2; ACTUAL_365 = 1; ACTUAL_ACTUAL = 1; d30_360 = 0; ...

Delphi 7 to Delphi XE
Have been using Delphi 7 for many moons ( have got later versions but never upgraded to ) My first problem is: Component Palette. in XE it is a small toolbar docked in top right in Delphi 7 it gives a large view of all the components. I am struggling to be able to cope/access my components.in Delphi XE. Can I make the component pallette tool bar the same size as Delphi 7, or is there a fast way to view/choose all available components in XE, that I have not spotted yet? Kind Regards, Robert. Hi, What I know is that in Delphi 2010 and XE you can choose between t...

Delphi 7 to Delphi XE2
Hi, Still using that old workhorse, Delphi7, but am going to the conference in London hosted by Embarcadero on Delphi XE2. Although I would like to "move with the times" and am keen to get the UNICODE and 64-bit support offered by the latest IDEs, I confess to being more than a little scared about all the UNICODE/String/AnsiString and 32/64 bit issues I'm probably going to fall over. Anyone recently upgraded from Delphi7 to one of the latest Delphi IDEs? Thanks, Alain On 03/02/2012 08:55, Alain Dekker wrote: > Still using that old workhorse, Delphi7, but...

SEPA components for Delphi with Source Code (Delphi 5
Hi all, in the european union change next year the Bankingformat to the SEPA Format. All peoples and companies must change the bankingssoftware and the costumer data form acountnummers in the new IBAN and BIC numbers. See: http://www.arma-it.de/shop/artikelueber.php?wgruppeid=211&wgruppe_offen=211 Functions: - generate SEPA XML'S - Calc IBAN - BIC Database (DE,AT and CH) Questions: vertrieb@arma-it.de PS: Bankinssoftware for Develpoers (Germany only) http://www.arma-it.de/shop/artikelueber.php?wgruppeid=212&wgruppe_offen=212 El 26/10/13 21:38, A...

New at ODBC ADO in Delphi, trying to locate resources [Edit]
I have an SQL database In Delphi I drop an ADOConnection1 and have no problem connecting to the table using the Browse button I can compile and run it When the form opens i want to be able to do procedure TForm1.FormCreate(Sender: TObject); begin ADOConnection1.Open; //works ADODataset1.First; //error Index := ADODataset1.RecordCount; //error Edit1.Text := IntToStr(Index); end; end. To show the number of records in the table. I know I am doing something wrong with the lines that have //error but can not locate good docs or examples for those command Maybe s...

Delphi 7 TFontDialog and Windows 7 [Edit]
When using the TFontDialog on a Windows 7 box, it will not list the device fonts (printer fonts). If I launch M$ Word on that same machine, Word will list them fine. This works fine on an XP box. Any ideas? Edited by: Tim Muenstermann on Apr 29, 2010 9:05 AM > {quote:title=Tim Muenstermann wrote:}{quote} > When using the TFontDialog on a Windows 7 box, it will not list the device fonts (printer fonts). If I launch M$ Word on that same machine, Word will list them fine. > What Word does (BTW, M$ went out about a decade ago) makes absolutely no difference. Office ...

Web resources about - Delphi 7 with ADO DBGrid, entering contents of record into variables. [Edit] - embarcadero.delphi.ado

Variable - Wikipedia, the free encyclopedia
Text is available under the Creative Commons Attribution-ShareAlike License ;additional terms may apply. By using this site, you agree to the ...

Westpac interest rate rise is one of many variable loan rate rises
WESTPAC is not alone in hitting its owner-occupier customers with a surprise interest rate rise, as dozens of other variable rate home loans ...

Airbnb upgrades variable pricing tool for hosts
Online home rental group Airbnb is rolling out an upgraded variable pricing tool that automatically raises or cuts room rates based on supply ...

Commonwealth Bank raises variable home loan rates
Home owners' mortgage costs are set to rise by hundreds of dollars a year, after the Commonwealth Bank became the latest bank to hike interest ...

CBA lifts variable home loan rates to offset costs associated with stricter capital requirements
The Commonwealth Bank to lift its home loan interest rates independently of the Reserve Bank to partially offset costs associated with stricter ...

Washington Square Signs Spielbergs, Choi Joins Variable and More
... films and an episode of the HBO comedy series "Girls," on which he plays the role of Ray Ploshansky. New York-based creative collective Variable ...

YouTube v10.32 Tweaks Some Interface Elements And Includes Hints About Virtual Reality Content And Variable ...
Forget Update Wednesday! Monday is the new big day. Not only were we treated to the latest M preview release and the official Marshmallow name, ...

"You have to ignore many variables to think women are paid less than men. California is happy to try." ...
Writes Sarah Ketterer in The Wall Street Journal in "The ‘Wage Gap’ Myth That Won’t Die" (which you can get to without subscribing if you Google ...

Cisco Debuts Open Pay Variable Pricing, Updates CCRE
Cisco Debuts Open Pay Variable Pricing, Updates CCRE Channel Partners Kris Snow, president of Cisco Capital, says the company's new Open Pay ...

Expert Reveals the Latest Variable Capacity Technology
Learn about gForce Ultra CRAC equipment, the latest variable capacity technology to lower energy usage and increase reliability.

Resources last updated: 11/22/2015 2:41:42 PM