我和你的遭遇一样。我用BDE连正常,后来换用IBX控件屡费周折。
如果用BDE连,要特别注意TSession的运用,还有,在设计期一定要把Database,Table,
Query等控件的Active设为false,另外写代码来初始化和打开连接。
以下是一个在Win2k,IB5.1.1,IIS5, IE5.5上通过的程序。
我把DFM和PAS都给你。程序中有
IbDBase: TDatabase;
MyTable: TTable;
Default: TDataSetTableProducer;
一个Action Item: Default 激活时将TTable中的内容列出。
// *.DFM
object WebDisp: TWebDisp
OldCreateOrder = False
OnCreate = WebModuleCreate
OnDestroy = WebModuleDestroy
Actions = <
item
Default = True
Name = 'default'
PathInfo = '/default'
OnAction = WebModule1defaultAction
end>
Left = 192
Top = 103
Height = 480
Width = 696
object MyTable: TTable
DatabaseName = 'DOC'
IndexFieldNames = 'DOCKEY'
TableName = 'DOC'
Left = 40
Top = 56
object MyTableDOCKEY: TStringField
FieldName = 'DOCKEY'
FixedChar = True
Size = 100
end
object MyTableDOCLOCATION: TMemoField
FieldName = 'DOCLOCATION'
BlobType = ftMemo
Size = 32767
end
end
object IBDbase: TDatabase
DatabaseName = 'DOC'
DriverName = 'INTRBASE'
LoginPrompt = False
Params.Strings = (
'SERVER NAME=C:/Interbase/DOC.GDB'
'USER NAME=SYSDBA'
'PASSWORD=masterkey')
SessionName = 'Default'
Left = 96
Top = 56
end
object default: TDataSetTableProducer
Columns = <
item
FieldName = 'DOCKEY'
end
item
FieldName = 'DOCLOCATION'
end>
DataSet = MyTable
Left = 40
Top = 120
end
end
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Classes, HTTPApp, DBWeb, Db, DBTables;
type
TWebDisp = class(TWebModule)
MyTable: TTable;
IBDbase: TDatabase;
MyTableDOCKEY: TStringField;
MyTableDOCLOCATION: TMemoField;
default: TDataSetTableProducer;
procedure WebModule1defaultAction(Sender: TObject;
Request: TWebRequest; Response: TWebResponse; var Handled: Boolean);
procedure WebModuleCreate(Sender: TObject);
procedure WebModuleDestroy(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
WebDisp: TWebDisp;
implementation
{$R *.DFM}
procedure TWebDisp.WebModule1defaultAction(Sender: TObject;
Request: TWebRequest; Response: TWebResponse; var Handled: Boolean);
begin
Response.Content:= Default.Content;
Response.SendResponse;
end;
procedure TWebDisp.WebModuleCreate(Sender: TObject);
begin
IbDbase.Connected:=true;
MyTable.Active:=true;
end;
procedure TWebDisp.WebModuleDestroy(Sender: TObject);
begin
MyTable.Active:=false;
IbDbase.Connected:=false;
end;
end.