全國最多中醫師線上諮詢網站-台灣中醫網
發文 回覆 瀏覽次數:1511
推到 Plurk!
推到 Facebook!

TDBGrid與TWDBGrid 轉換後的錯誤

缺席
u86210779
一般會員


發表:16
回覆:41
積分:16
註冊:2004-06-08

發送簡訊給我
#1 引用回覆 回覆 發表時間:2007-01-29 08:30:37 IP:220.142.xxx.xxx 訂閱
請教各位先進:
我是使用繼承的方式. B Form 繼承 A Form, A Form 中有個 DBGrid1.
請問
1.當將所有的 TDBGrid 改為 TWDBGrid 後, 每次開啟 B Form 會出現 Acess Violation Address 4034e073 in module 'dbrtl70.bpl'. Read of Address 0000000. 錯誤訊息. 要如何處理
2.在 B Form 中無論如何修改 Color 屬性, 執行後均為 clBtnFace, 應該在哪裡修改 DBGrid.Color 才對.
謝謝你
hagar
版主


發表:143
回覆:4056
積分:4445
註冊:2002-04-14

發送簡訊給我
#2 引用回覆 回覆 發表時間:2007-01-31 11:59:52 IP:59.124.xxx.xxx 未訂閱
怎麼繼承的?發生錯誤的那行程式碼為何?
u86210779
一般會員


發表:16
回覆:41
積分:16
註冊:2004-06-08

發送簡訊給我
#3 引用回覆 回覆 發表時間:2007-02-01 08:57:26 IP:220.142.xxx.xxx 訂閱
底下為三個程式的部分原始碼, 請參考.
原本要用附加檔案的方式, 找不到按鍵在哪裡.
不是 RunTime 時發生錯誤, 而是在 Codeing 時, 開啟那個 Form 產生的錯誤.
unit uBase;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, DB, StdCtrls, Mask, Buttons, Grids, DBGrids, ADODB;

type
TBase = class(TForm)
procedure FormCreate(Sender: TObject);
procedure FormClose(Sender: TObject; var Action: TCloseAction);
private
{ Private declarations }
public
procedure DBOpen; virtual;
procedure OpenDB; virtual;
procedure GetData(vLeft: integer; vNO, vCaption, vSQLStr, vKeyField,
vDataSource, vField0, vField1, vField2: string);
procedure PutData(vLeft: integer; vNO, vCaption, vSQLStr, vKeyField,
vDataSource, vField0, vField1, vField2: string);
{ Public declarations }
end;

var
Base: TBase;

implementation
uses uHand, uDataModule1, uSelect, uPublicUtility;
{$R *.dfm}
procedure TBase.FormCreate(Sender: TObject);
begin
try
fmHand:=TfmHand.Create(Self);
with fmHand do begin
Caption := '開啟檔案中, 請稍後';
Gauge2.MaxValue := 100;
Gauge2.MinValue := 0;
Gauge2.Progress := 0;
show;
DBOpen; //開啟參考 table
OpenDB; //開啟主要 table
Gauge2.Progress := 100;
free;
end;
except
MessageDlg('資料庫開啟錯誤, 請洽系統管理人員 !!', mtError, [mbAbort],0);
fmHand.Free;
Close;
end;
end;

procedure TBase.FormClose(Sender: TObject; var Action: TCloseAction);
var i: integer;
begin
try
for i := 1 to ComponentCount - 1 do
if Components[i] is TADOQuery then
with (Components[i] as TADOQuery) do begin
if state in [dsEdit, dsInsert] then Cancel; //寫入資料
Close; //關閉各個 table
end; //with
action := caFree;
except
MessageDlg('關檔錯誤, 請洽系統管理人員 !!', mtError, [mbAbort],0);
raise;
end;
end;

procedure TBase.DBOpen;
begin
//
end;

procedure TBase.OpenDB;
begin
//
end;

procedure TBase.GetData(vLeft: integer; vNO, vCaption, vSQLStr,
vKeyField, vDataSource, vField0, vField1, vField2: string);
var i : integer;
begin
fmSelect:=TfmSelect.Create(Self);
fmSelect.vNo := vNo;
with fmSelect do begin
with qySelect do begin
close;
sql.clear;
sql.add(vSQLStr);
OPEN;
end;
Left := vLeft;
Caption := vCaption;
DBGrid1.Columns[0].Title.Caption := vField0;
DBGrid1.Columns[1].Title.Caption := vField1;
DBGrid1.Columns[2].Title.Caption := vField2;

showModal;
end;
//return OK and not null
if fmSelect.modalResult=mrOK then begin
for i := 1 to (ComponentCount - 1) do begin
if (Components[i] is TDataSource) and ((Components[i] as TDataSource).name = vDataSource) then begin
(Components[i] as TDataSource).DataSet.locate(vKeyField,fmSelect.vNo,[]);
end; //if Components[i] is TDataSource
end; //for
end; //if Result ok

fmSelect.Free;
end;

procedure TBase.PutData(vLeft: integer; vNO, vCaption, vSQLStr, vKeyField,
vDataSource, vField0, vField1, vField2: string);
var i : integer;
begin
fmSelect:=TfmSelect.Create(Self);
fmSelect.vNo := vNo;
with fmSelect do begin
with qySelect do begin
close;
sql.clear;
sql.add(vSQLStr);
OPEN;
end;
Left := vLeft;
Caption := vCaption;
DBGrid1.Columns[0].Title.Caption := vField0;
DBGrid1.Columns[1].Title.Caption := vField1;
DBGrid1.Columns[2].Title.Caption := vField2;

showModal;
end;
//return OK and not null
if fmSelect.modalResult=mrOK then begin
for i := 1 to (ComponentCount - 1) do begin
if (Components[i] is TDataSource) and ((Components[i] as TDataSource).name = vDataSource) then begin
(Components[i] as TDataSource).DataSet.FieldByName(vKeyField).AsString := fmSelect.vNO;
end; //if Components[i] is TDataSource
end; //for
end; //if Result ok

fmSelect.Free;
end;

end.
unit uSingle;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, uBase, StdCtrls, Mask, DBCtrls, Buttons, DB, dbcgrids, Grids,
DBGrids, WDBGrid;

type TMyData = record
vLeft: integer;
vNo, vCaption, vSQLStr, vKeyField, vDataSource: string;
vField0, vField1, vField2: string;
end;

type
TSingle = class(TBase)

......
end.
unit uPlnk;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, uSingle, DB, ADODB, StdCtrls, Mask, DBCtrls, dbcgrids, Buttons,
Grids, DBGrids, WDBGrid;

type
TfmPlnk = class(TSingle)
qyPlnk: TADOQuery;
qyRn: TADOQuery;
qyPlnkPLNK_NAME: TStringField;
qyPlnkRN_NO: TStringField;
qyPlnkrn_name: TStringField;
qyPlnkREMARK: TStringField;
qyPlnkPLNK_NO: TStringField;

.......
end.


===================引 用 文 章===================

怎麼繼承的?發生錯誤的那行程式碼為何?
系統時間:2024-05-15 4:18:02
聯絡我們 | Delphi K.Top討論版
本站聲明
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。
2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。
3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇!