|
Haha, it seems that the difficulty of this problem is not small. In general, there are many solutions. Of course, the problem lies mainly in Borland.
1. Modify the source code of ADODB.pas, that is, modify the field definition part converted from Recordset to DataSet. This issue has been discussed by many people. Forcibly modify the correspondence relationship of decimal
2. Modify the source code of DB.pas, that is, if ADO calls data directly from the Recordset
3. Create a new custom field class, such as TDoubleField, and then define it yourself. Of course, you have to modify the source code of ADODB.pas and DB.pas at this time.
The above three methods are once and for all methods, preferably the third method
The fourth method, this situation is suitable for the case where there are fewer such fields, which is to modify the GetText and SetText methods of the field, such as
procedure TForm1.ADOQuery1DecFieldSetText(Sender: TField; const Text: String);
begin
ADOQuery1.Recordset.AbsolutePosition:=ADOQuery1.RecNo;
ADOQuery1.Recordset.Fields[1].Value:=Text;
end;
procedure TForm1.ADOQuery1DecFieldGetText(Sender: TField; var Text: String; DisplayText: Boolean);
begin
ADOQuery1.Recordset.AbsolutePosition:=ADOQuery1.RecNo;
Text:=VarToStr(ADOQuery1.Recordset.Fields[1].Value);
end;
Of course, due to Borland's inherent shortcomings, the actual code may be more, and a lot of judgments need to be added. In fact, the basic principle is similar to the previous method, which is to bypass Borland's field definitions and write data directly to the Recordset.
5. This method is generally too rosy, that is, directly bypassing the data sensing controls to operate, so that you can do whatever you want.
In general, the third method is the best |
|