编译运行报'table do se not exist ,对象名zhiydoc无效,而表在数据库中存在,请问高手是怎么回事(50分)

  • 主题发起人 主题发起人 nfsong
  • 开始时间 开始时间
N

nfsong

Unregistered / Unconfirmed
GUEST, unregistred user!
unit w_dlcs;<br><br>interface<br><br>uses<br> &nbsp;Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,<br> &nbsp;Dialogs, StdCtrls, ExtCtrls, DB, DBTables,IniFiles, Grids, DBGrids;<br><br>type<br> &nbsp;Tw_dlfrm = class(TForm)<br> &nbsp; &nbsp;Panel1: TPanel;<br> &nbsp; &nbsp;Image1: TImage;<br> &nbsp; &nbsp;Label1: TLabel;<br> &nbsp; &nbsp;Label2: TLabel;<br> &nbsp; &nbsp;E_user: TEdit;<br> &nbsp; &nbsp;E_pwd: TEdit;<br> &nbsp; &nbsp;B_yes: TButton;<br> &nbsp; &nbsp;B_quit: TButton;<br> &nbsp; &nbsp;dlfrm_dbg: TDBGrid;<br> &nbsp; &nbsp;procedure FormCreate(Sender: TObject);<br> &nbsp; &nbsp;procedure B_quitClick(Sender: TObject);<br> &nbsp; &nbsp;procedure B_yesClick(Sender: TObject);<br> &nbsp; &nbsp;procedure E_userDblClick(Sender: TObject);<br> &nbsp; &nbsp;procedure E_userKeyDown(Sender: TObject; var Key: Word;<br> &nbsp; &nbsp; &nbsp;Shift: TShiftState);<br> &nbsp;private<br> &nbsp; &nbsp;{ Private declarations }<br> &nbsp;public<br> &nbsp; &nbsp;{ Public declarations }<br> &nbsp; &nbsp;procedure db_link; &nbsp;//数据库连接,公用<br> &nbsp;end;<br><br>var<br> &nbsp;w_dlfrm: Tw_dlfrm;<br><br>implementation<br><br>{$R *.dfm}<br>uses w_log,M_datahz;<br><br>procedure Tw_dlfrm.FormCreate(Sender: TObject);<br>var dl_times:integer;<br> &nbsp; &nbsp;Dbini:TiniFile;<br> &nbsp; &nbsp;filebm:string;<br> &nbsp; &nbsp;a_alias:string;<br> &nbsp; &nbsp;BDEalias:TstringList;<br> &nbsp; &nbsp;Bdesession:Tsession;<br>begin<br> &nbsp;dlfrm_dbg.Hide;<br> &nbsp;dl_times:=0;<br> &nbsp;filebm:=ExtractFilePath(paramstr(0))+'mydb.ini';<br> &nbsp;Dbini:=TiniFile.Create(filebm);<br> &nbsp;a_alias:=Dbini.ReadString('数据库登录','AliasName','');<br> &nbsp;BDEAlias:=TstringList.Create;<br> &nbsp;Bdesession:=Tsession.Create(self);<br> &nbsp;Bdesession.AutoSessionName:=true;<br> &nbsp;Bdesession.GetAliasNames(BdeAlias);<br> &nbsp;//如果BDE中不存在mdb.ini中的别名设置,就显示设置参数窗体<br> &nbsp;if (BDEAlias.IndexOf(a_alias)=-1) or (a_alias='') then<br> &nbsp; &nbsp;begin<br> &nbsp; &nbsp; &nbsp;MessageDlg('数据库参数设置错误,请检查设置!',Mterror,[mbok],0);<br> &nbsp; &nbsp; &nbsp;try<br> &nbsp; &nbsp; &nbsp; &nbsp;w_csfrm:=TW_csfrm.Create(self);<br> &nbsp; &nbsp; &nbsp; &nbsp;w_csfrm.c_alias.Text:=trim(Dbini.ReadString('数据库登录','AliasName',''));<br> &nbsp; &nbsp; &nbsp; &nbsp;w_csfrm.c_dbmc.Text:=trim(Dbini.ReadString('数据库登录','Database',''));<br> &nbsp; &nbsp; &nbsp; &nbsp;w_csfrm.c_server.Text:=trim(Dbini.ReadString('数据库登录','ServerName',''));<br> &nbsp; &nbsp; &nbsp; &nbsp;w_csfrm.c_dlmc.Text:=trim(Dbini.ReadString('数据库登录','LogId',''));<br> &nbsp; &nbsp; &nbsp; &nbsp;w_csfrm.c_mm.Text:=trim(Dbini.ReadString('数据库登录','Logpassword',''));<br> &nbsp; &nbsp; &nbsp; &nbsp;w_csfrm.ShowModal;<br> &nbsp; &nbsp; &nbsp;finally<br> &nbsp; &nbsp; &nbsp; &nbsp;W_csfrm.Free;<br> &nbsp; &nbsp; &nbsp; &nbsp;Bdesession.AutoSessionName:=false;<br> &nbsp; &nbsp; &nbsp; &nbsp;Bdesession.Free;<br> &nbsp; &nbsp; &nbsp;end;<br> &nbsp; &nbsp;end;<br>end;<br><br><br>procedure Tw_dlfrm.B_quitClick(Sender: TObject);<br>begin<br> &nbsp;close;<br>end;<br><br>procedure Tw_dlfrm.db_link;<br>var Dbini:TiniFile;<br> &nbsp; &nbsp;filebm:string;<br>begin<br> &nbsp;filebm:=ExtractFilePath(paramstr(0))+'mydb.ini';<br> &nbsp;Dbini:=TiniFile.Create(filebm);<br> &nbsp;M_mxhz:=TM_mxhz.Create(self);<br> &nbsp;with M_mxhz do<br> &nbsp; &nbsp;try<br> &nbsp; &nbsp; &nbsp;dlfrm_DB.AliasName:=dbini.ReadString('数据库登录','AliasName','');<br> &nbsp; &nbsp; &nbsp;dlfrm_DB.DatabaseName:=dbini.ReadString('数据库登录','Database','');<br> &nbsp; &nbsp; &nbsp;dlfrm_DB.Params.Add('Server Name='+dbini.ReadString('数据库登录','ServerName',''));<br> &nbsp; &nbsp; &nbsp;dlfrm_DB.Params.Add('User Name='+dbini.ReadString('数据库登录','LogId',''));<br> &nbsp; &nbsp; &nbsp;dlfrm_DB.Params.Add('PassWord='+dbini.ReadString('数据库登录','LogPassword',''));<br> &nbsp; &nbsp; &nbsp;dlfrm_DB.LoginPrompt:=false;<br> &nbsp; &nbsp; &nbsp;dlfrm_DB.DriverName:='MSSQL';<br> &nbsp; &nbsp; &nbsp;dlfrm_Qry.DatabaseName:=dlfrm_DB.DatabaseName;<br> &nbsp; &nbsp; &nbsp;dlfrm_DB.Connected:=true;<br> &nbsp; &nbsp;except<br> &nbsp; &nbsp; &nbsp;raise;<br> &nbsp; &nbsp; &nbsp;dlfrm_DB.Free;<br> &nbsp; &nbsp; &nbsp;dlfrm_qry.Free;<br> &nbsp; &nbsp;end;<br>end;<br><br>procedure Tw_dlfrm.B_yesClick(Sender: TObject);<br>begin<br> close;<br>end;<br><br>procedure Tw_dlfrm.E_userDblClick(Sender: TObject);<br>begin<br> &nbsp;db_link;<br> &nbsp;with M_mxhz do<br> &nbsp; &nbsp;try<br> &nbsp; &nbsp; &nbsp;dlfrm_qry.Close;<br> &nbsp; &nbsp; &nbsp;dlfrm_Qry.SQL.Clear;<br> &nbsp; &nbsp; &nbsp;dlfrm_Qry.SQL.Add('select dzycode,dzyname from zhiydoc');<br> &nbsp; &nbsp; &nbsp;dlfrm_Qry.Prepare;<br> &nbsp; &nbsp; &nbsp;dlfrm_Qry.open;<br> &nbsp; &nbsp;except<br> &nbsp; &nbsp; &nbsp;raise;<br> &nbsp; &nbsp; &nbsp;dlfrm_qry.Free;<br> &nbsp; &nbsp;end;<br> &nbsp;dlfrm_dbg.Show;<br>end;<br><br>procedure Tw_dlfrm.E_userKeyDown(Sender: TObject; var Key: Word;<br> &nbsp;Shift: TShiftState);<br>begin<br> &nbsp;Db_link;<br> &nbsp;if E_user.Text&lt;&gt;'' then<br> &nbsp; &nbsp;M_mxhz:=TM_mxhz.Create(self);<br> &nbsp; &nbsp;with M_mxhz do<br> &nbsp; &nbsp;try<br> &nbsp; &nbsp; &nbsp;dlfrm_qry.Close;<br> &nbsp; &nbsp; &nbsp;dlfrm_qry.SQL.Clear;<br> &nbsp; &nbsp; &nbsp;dlfrm_qry.SQL.Add('select dzycode,dzyname from zhiydoc');<br> &nbsp; &nbsp; &nbsp;dlfrm_qry.SQL.Add('where (dzycode like :A or dzyname like :B or zjm like :C)');<br> &nbsp; &nbsp; &nbsp;dlfrm_qry.ParamByName('A').AsString:=trim(E_user.Text)+'%';<br> &nbsp; &nbsp; &nbsp;dlfrm_qry.ParamByName('B').AsString:='%'+trim(E_user.Text)+'%';<br> &nbsp; &nbsp; &nbsp;dlfrm_qry.ParamByName('C').AsString:='%'+trim(E_user.Text)+'%';<br> &nbsp; &nbsp; &nbsp;dlfrm_qry.Active:=true;<br> &nbsp; &nbsp; &nbsp;dlfrm_qry.Prepare;<br> &nbsp; &nbsp; &nbsp;dlfrm_qry.Open;<br> &nbsp; &nbsp;except<br> &nbsp; &nbsp; &nbsp;dlfrm_qry.Free;<br> &nbsp; &nbsp; &nbsp;raise;<br> &nbsp; &nbsp;end;<br> &nbsp;dlfrm_dbg.Show;<br>end;<br><br>end.<br><br>初学delphi,请大家多多指教!
 
怎么会没人理呢?这么大的论坛。
 
错误提示那么明显,还要人家怎么答?<br>zhiydoc表不存在啊!你检查下你的数据库再说。<br>注意下你的拼写,看看是不是多了字符,少了字符什么的。
 
可能是你的登录用户不对,你用SA用户试试,如果存在,是不是你的用户没有权限存取这个表
 
TM_mxhz是什么?没看出来<br>另外,dlfrm_qry没有指定Connectionstring
 
TM_mxhz = class(TDataModule),我是用BDE连接SQL2000的,表明明在数据库中存在,我估计是不是数据库初始化连接有问题?本人刚学,好多东东都在慢慢探索,还请大家指点,还要一个问题,如果编写一个进销存软件,数据库连接是在OnCreate事件只连接一次就可以了,还是要在需要的时候就连接?
 
后退
顶部