New to Delphi

Hi

I used to be a VB 6 Programmer and now I have started Delphi, few days ago.

I am looking for some way in Delphi, where we can select records in a RECORDSET and then that RECORDSET can be used to compare , displaying or decision making.

2- A method other than INSERT INTO for adding records to database,
like in VB we do ADD NEW and then specify individual records and their values.

so actually i want to translate following VB 6 code into Delphi by using ADO.

rs.open "Select * from table-1" ,cn,2,3

field1.text=rs![name]
field2.text=rs![age]

rs.close

or

rs.open "Select * from table-1" ,cn,2,3

rs.add
rs![name]=field1.text
rs![age]=field1.text
rs.update
rs.close



thanks
hellorazaAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

jimyXCommented:
In Delphi the common ADO Components are ADOConnection, ADOTable and ADOQuery.

You use the ADOConnection to setup the connection to your database, by intializing the connection via the property "ConnectionString". Then use AdoQuery or AdoTable to connect to your table(s) in that DB, after adjusting the property "Connection".

The AdoQuery uses SQL to fetch data from the DB Table, AdoTable loads the entire Table when connected, so you better use AdoQuery.


To load data from your table:
  // AdoQuery
  AdoQuery1.Close;
  AdoQuery1.SQL.Text := 'Select * from YourTableName';
  AdoQuery1.Open;
  Edit1.Text := AdoQuery1.FieldByName('name').AsString;
  Edit2.Text := AdoQuery1.FieldByName('age').AsString;
  AdoQuery1.Close;

  // AdoTable
  // You must set the Table Name property to identify the intended Table
  AdoTable1.Open;
  Edit1.Text := AdoTable1.FieldByName('name').AsString;
  Edit2.Text := AdoTable1.FieldByName('age').AsString;
  AdoTable1.Close;


To insert data to your Table:
  // AdoQuery
  AdoQuery1.Close;
  AdoQuery1.SQL.Text := 'Insert into YourTableName (name, age) Values ('+QuotedStr(Edit1.Text)+', '+QuotedStr(Edit2.Text)+')';
  AdoQuery1.ExecSQL;

  // Or you can use Parameters
  AdoQuery1.Close;
  AdoQuery1.SQL.Text := 'Insert into YourTableName (name, age) Values (:ParaName, :ParaAge)';
  AdoQuery1.Parameters.ParamByName('ParaName').AsString := Edit1.Text;
  AdoQuery1.Parameters.ParamByName('ParaAge').AsString := Edit2.Text;
  AdoQuery1.ExecSQL;

  // AdoTable
  ADOTable1.Insert;
  ADOTable1.FieldByName('name').AsString := Edit1.Text;
  ADOTable1.FieldByName('age').AsString := Edit2.Text;
  ADOTable1.Post;

  // Or
  ADOTable1.InsertRecord(Edit1.Text, Edit2.Text);


You did the right thing by moving to Delphi.

PS: I just provided a quick info here, but you need to read a complete reference to learn more about how to use Delphi Database.
0
hellorazaAuthor Commented:

Thanks .

Can you please recommend me any website, where I can find some sample applications to get an idea about language basics and some tips and tricks.

regards.
0
jimyXCommented:
There are many sites actually, but right now I have two in mind Torry's and About Delphi.

Also you can google for articles, free lessons or any particular issue you would like to learn about.

And of course EE will back you up if you needed support.
0
PMI ACP® Project Management

Prepare for the PMI Agile Certified Practitioner (PMI-ACP)® exam, which formally recognizes your knowledge of agile principles and your skill with agile techniques.

jimyXCommented:
About Delphi is full of samples and tips & Tricks. Also Torry.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
hellorazaAuthor Commented:
Thanks
0
jimyXCommented:
Here is a nice book "Mastering Delphi 7"
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Delphi

From novice to tech pro — start learning today.