helloraza
asked on
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
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
ASKER
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.
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.
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.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks
Here is a nice book "Mastering Delphi 7"
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('nam
Edit2.Text := AdoQuery1.FieldByName('age
AdoQuery1.Close;
// AdoTable
// You must set the Table Name property to identify the intended Table
AdoTable1.Open;
Edit1.Text := AdoTable1.FieldByName('nam
Edit2.Text := AdoTable1.FieldByName('age
AdoTable1.Close;
To insert data to your Table:
// AdoQuery
AdoQuery1.Close;
AdoQuery1.SQL.Text := 'Insert into YourTableName (name, age) Values ('+QuotedStr(Edit1.Text)+'
AdoQuery1.ExecSQL;
// Or you can use Parameters
AdoQuery1.Close;
AdoQuery1.SQL.Text := 'Insert into YourTableName (name, age) Values (:ParaName, :ParaAge)';
AdoQuery1.Parameters.Param
AdoQuery1.Parameters.Param
AdoQuery1.ExecSQL;
// AdoTable
ADOTable1.Insert;
ADOTable1.FieldByName('nam
ADOTable1.FieldByName('age
ADOTable1.Post;
// Or
ADOTable1.InsertRecord(Edi
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.