PROBLEM
I have DBGdrid
and there are columns what show ID's
from an MS Access database. How can I change them to real values like item name, client name, employee name
?
I have code (test code, I just tried to get all items names from table and I could save them to array or variable and change with DBGrid
values what show id's), but I don't know how to change DBGrid
value fields.
procedure TForm2.Button1Click(Sender: TObject);
var i,j:integer; mas:string;
begin
Button1.Enabled := false;
Button2.Enabled := true;
Button3.Enabled := true;
Form1.ADOQuery1.SQL.Text := 'SELECT * FROM items_specification';
Form1.ADOQuery1.Open;
j:= Form1.ADOQuery1.RecordCount;
Form1.ADOQuery1.Close;
i:=1;
repeat
Form1.ADOQuery1.SQL.Text := 'SELECT * FROM items_specification WHERE item_id = :ID';
Form1.ADOQuery1.Parameters.ParamByName('ID').Value := i;
Form1.ADOQuery1.Open;
mas:= Form1.ADOQuery1['item_name'];
Form1.ADOQuery1.Close;
inc(i);
ShowMessage(mas) ;
until (i = j+1);
Maybe you have any suggestions how to solve the problem, I will appreciate that.
In MS Access I have made look up to show names there, mby there is some way to do that in DBGrid
?
UPDATED
But code doesn't matter.. My big question is how to set item name, client name and employee name in DBGrid
(in values not column title)?! In MS Access those fields where is id is number, so if I even edit DBGrid
it don't allow me to change value to string.. Only way what I could imagine is to broke relationships in MS Access and change fields to ShortText
, but I think is not the best way.