照着李维的《高效数据库编程》抄代码,遇到错误过不去,请帮助

jungle_1978 2003-12-11 02:14:46
浏览记录没有问题,但是当且仅做了任何的修改之后,
点apply updates按钮发现下面两个错误

ora-00942 table or view does not exist

raised exception class edatabaseerror with message 'unable to find
record. no key specified'.

源文件如下(书里第一章):
object Form1: TForm1
Left = 192
Top = 107
Width = 696
Height = 480
Caption = 'Form1'
Color = clBtnFace
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -11
Font.Name = 'MS Sans Serif'
Font.Style = []
OldCreateOrder = False
PixelsPerInch = 96
TextHeight = 13
object Label1: TLabel
Left = 208
Top = 104
Width = 40
Height = 13
Caption = 'BANKID'
FocusControl = DBEdit6
end
object Label2: TLabel
Left = 208
Top = 144
Width = 59
Height = 13
Caption = 'BANKCODE'
FocusControl = DBEdit7
end
object Label3: TLabel
Left = 208
Top = 184
Width = 31
Height = 13
Caption = 'NAME'
FocusControl = DBEdit8
end
object Label4: TLabel
Left = 208
Top = 224
Width = 20
Height = 13
Caption = 'FAX'
FocusControl = DBEdit9
end
object Label6: TLabel
Left = 208
Top = 264
Width = 20
Height = 13
Caption = 'TEL'
FocusControl = DBEdit10
end
object DBNavigator1: TDBNavigator
Left = 0
Top = 8
Width = 680
Height = 25
DataSource = DataSource1
TabOrder = 0
end
object BitBtn1: TBitBtn
Left = 488
Top = 96
Width = 137
Height = 33
Caption = 'Apply Updates'
TabOrder = 1
OnClick = BitBtn1Click
Kind = bkAll
end
object DBEdit6: TDBEdit
Left = 208
Top = 120
Width = 134
Height = 21
DataField = 'BANKID'
DataSource = DataSource1
TabOrder = 2
end
object DBEdit7: TDBEdit
Left = 208
Top = 160
Width = 56
Height = 21
DataField = 'BANKCODE'
DataSource = DataSource1
TabOrder = 3
end
object DBEdit8: TDBEdit
Left = 208
Top = 200
Width = 316
Height = 21
DataField = 'NAME'
DataSource = DataSource1
TabOrder = 4
end
object DBEdit9: TDBEdit
Left = 208
Top = 240
Width = 134
Height = 21
DataField = 'FAX'
DataSource = DataSource1
TabOrder = 5
end
object DBEdit10: TDBEdit
Left = 208
Top = 280
Width = 303
Height = 21
DataField = 'TEL'
DataSource = DataSource1
TabOrder = 6
end
object Edit1: TEdit
Left = 96
Top = 392
Width = 433
Height = 21
TabOrder = 7
Text = 'Edit1'
end
object DataSource1: TDataSource
DataSet = SimpleDataSet1
Left = 144
Top = 232
end
object SimpleDataSet1: TSimpleDataSet
Active = True
Aggregates = <>
Connection.ConnectionName = 'OracleConnection'
Connection.DriverName = 'Oracle'
Connection.GetDriverFunc = 'getSQLDriverORACLE'
Connection.LibraryName = 'dbexpora.dll'
Connection.LoginPrompt = False
Connection.Params.Strings = (
'DriverName=Oracle'
'DataBase=jhjf1'
'User_Name=oss'
'Password=wlklhb'
'RowsetSize=20'
'BlobSize=-1'
'ErrorResourceFile='
'LocaleCode=0000'
'Oracle TransIsolation=ReadCommited'
'OS Authentication=False'
'Multiple Transaction=False'
'Trim Char=False')
Connection.VendorLib = 'oci.dll'
Connection.Connected = True
DataSet.Active = True
DataSet.CommandText = 'select * from bankfax'
DataSet.MaxBlobSize = -1
DataSet.Params = <>
Params = <>
Left = 216
Top = 320
object SimpleDataSet1BANKID: TBCDField
FieldName = 'BANKID'
Required = True
Precision = 9
Size = 0
end
object SimpleDataSet1BANKCODE: TStringField
FieldName = 'BANKCODE'
Required = True
FixedChar = True
Size = 4
end
object SimpleDataSet1NAME: TStringField
FieldName = 'NAME'
Size = 24
end
object SimpleDataSet1FAX: TStringField
FieldName = 'FAX'
Size = 10
end
object SimpleDataSet1TEL: TStringField
FieldName = 'TEL'
Size = 23
end
end
end


unit Unit1;

interface

uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, DBXpress, FMTBcd, StdCtrls, Mask, DBCtrls, DB, ExtCtrls, SqlExpr,
Provider, DBClient, Buttons, SimpleDS;

type
TForm1 = class(TForm)
DataSource1: TDataSource;
DBNavigator1: TDBNavigator;
BitBtn1: TBitBtn;
SimpleDataSet1: TSimpleDataSet;
SimpleDataSet1BANKID: TBCDField;
SimpleDataSet1BANKCODE: TStringField;
SimpleDataSet1NAME: TStringField;
SimpleDataSet1FAX: TStringField;
SimpleDataSet1TEL: TStringField;
Label1: TLabel;
DBEdit6: TDBEdit;
Label2: TLabel;
DBEdit7: TDBEdit;
Label3: TLabel;
DBEdit8: TDBEdit;
Label4: TLabel;
DBEdit9: TDBEdit;
Label6: TLabel;
DBEdit10: TDBEdit;
Edit1: TEdit;
procedure BitBtn1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;

var
Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.BitBtn1Click(Sender: TObject);
begin
edit1.Text:=simpledataset1.DataSet.CommandText;
simpledataset1.ApplyUpdates(0);
end;

end.

...全文
20 点赞 收藏 8
写回复
8 条回复
切换为时间正序
请发表友善的回复…
发表回复
JoeSong 2003-12-13
这么长的代码我就不看了,不过我当时也按书上讲的也有地方过不去,所以就没按他的书的例子自己重新来写,就通过了。
回复
jungle_1978 2003-12-13
不懂了。
用主键有什么好处呢?
回复
ywzwyw 2003-12-12
'select * from bankfax'

将表名改成大写就可以了

select * from BANKFAX

SELECT * FROM BANKFAX
回复
santafeng 2003-12-12
表肯定有主键,那书我也有不过好象很多错悟地方或者没写的一部分过程,总之就乱.如果你不注重要用表的主键或这种技术的话建议不要用.反正其他dbexpress技术的都可以实现的.
回复
jungle_1978 2003-12-12
表是当然存在的!
怎么用simpledataset等dbexpress控件修改的表是一定要有主键的么?
回复
wave_f 2003-12-11
可能是环境的问题
回复
upingking 2003-12-11
看看你的数据库设计的是否和书上写的一致
回复
upingking 2003-12-11
ora-00942 table or view does not exist//视图或表不存在

raised exception class edatabaseerror with message 'unable to find
record. no key specified'.//没有主键
回复
发动态
发帖子
网络通信/分布式开发
创建于2007-08-02

1565

社区成员

Delphi 网络通信/分布式开发
申请成为版主
社区公告
暂无公告