在关键字'Use'附近有语法错误,请教是怎么回事?(100)

  • 主题发起人 主题发起人 yedixifeng
  • 开始时间 开始时间
Y

yedixifeng

Unregistered / Unconfirmed
GUEST, unregistred user!
软件在access中用起来一切正常。换成SQL2000后,出了点问题。代码如下:procedure TfrmBase2Info.LoadData;var sSql, sClassID: string;begin sSql := ''; sClassID := ''; case lMode of BASE_CLIENT: sSql := ' SELECT U.*,(U.Receive+UM.ARTotal-UM.DoARTotal)as OverARTotal' + ' FROM Unit AS U LEFT JOIN UnitMoney AS UM ON U.ID = UM.UnitID' + ' WHERE U.Mode = ' + IntTostr(lMode); BASE_PROVIDE: sSql := ' SELECT U.*,(U.Payable+UM.ARTotal-UM.DoARTotal)as OverARTotal' + ' FROM Unit AS U LEFT JOIN UnitMoney AS UM ON U.ID = UM.UnitID' + ' WHERE U.Mode = ' + IntTostr(lMode); BASE_EMPLOYE: sSql := 'SELECT * FROM Employe'; BASE_WARE: sSql := ' SELECT W.ID, W.TreeParent, W.UserCode, W.Name, W.ShortName, W.PinYin, W.Model, W.Spec,' + ' W.Area, W.Type, W.Unit, W.Unit2, W.Scale, W.Sort, W.BarCode, W.Pos_Price, W.Pos_Purch,' + ' W.ConstPrice, W.Price1, W.Price2, W.Price3, W.Price4, W.Up_Limit, W.Down_Limit, W.Memo, W.Use, W.Mode,' + ' Sum(WS.Number) AS SumNumber, Sum(WS.Total) AS SumTotal' + ' FROM Ware AS W LEFT JOIN WareStock AS WS ON W.ID = WS.WareID ' + ' GROUP BY W.ID, W.TreeParent, W.UserCode, W.Name, W.ShortName, W.PinYin, W.Model, W.Spec,' + ' W.Area, W.Type, W.Unit, W.Unit2, W.Scale, W.Sort, W.BarCode, W.Pos_Price, W.Pos_Purch,' + ' W.ConstPrice, W.Price1, W.Price2, W.Price3, W.Price4, W.Up_Limit, W.Down_Limit, W.Memo, W.Use, W.Mode'; BASE_DEPOT: sSql := 'SELECT * FROM Depot'; BASE_FIXED_ADD: sSql := 'SELECT * FROM FixedAssets WHERE [Delete]=FALSE'; BASE_FIXED_DEC: sSql := 'SELECT * FROM FixedAssetsDec '; BASE_WAGE_PROCEDURE: sSql := 'SELECT * FROM WageOrder'; BASE_WAGE_ITEM: sSql := 'SELECT * FROM WageItem'; BASE_SUBJECT: begin sSql := 'SELECT * FROM Subject where ClassID=' + IntToStr(tabCtrl.TabIndex + 1) + ' ' + sPlusSQL; end; end; AdoSetBase2 := AdoSetBase2Info; OpenDataSet(AdoSetBase2, sSql);end;运行后打开增加时,出现:在关键字'Use'附近有语法错误,再运行时,出现TreeParent不能发现,光标指到: if not ADOSetBase2.FieldByName('TreeParent').IsNull then请问,哪出了问题?
 
可能是W.Use 中的Use是关键字,你用[]把此字段括起来试试
 
好象不行,出现了 列名'Use'无效。
 
W.[Use]这样不行么?
 
W."Use"试试
 
两个Use都分别试了,两个都[]时,说排序错误什么的。
 
W."Use"也不行。
 
应该是环境变量被改变了 无法认到包文件 你从新引入一下
 
不太明白,如何重新引入?
 
Delphi世界qq群23981160
 
两个Use加了[]后出现:不能比较或排序 text、ntext 和 image 数据类型,除非使用 IS NULL 或 LIKE 运算符不知道原因了,请高手帮忙看看。
 
感谢各位,尤其感谢guqiu,换成W.[Use],改Ware中memo的数据类型ntext为nvarchar后,可以打开,但添加完数据保存时却遇到:缺少更新或刷新的基本表消息,光标指到:SaveDataSet(AdoSetBase2, False),这个问题好象是缺少关键字?请教高手,如何解决呢?代码如下:procedure TfrmBase2Info.bbAddClick(Sender: TObject);var bRet: boolean;begin inherited; bRet := false; lParentID := 0; lRootID := 0; if not ADOSetBase2.FieldByName('TreeParent').IsNull then begin lParentID := ADOSetBase2.FieldByName('TreeParent').asInteger; if lMode = BASE_SUBJECT then lRootID := ADOSetBase2.FieldByName('RootID').asInteger; end; ADOSetBase2.Filter := ''; AdoSetBase2.Last; AdoSetBase2.Insert; case lMode of BASE_CLIENT: bRet := Base2InfoUnitShow(lMode); BASE_PROVIDE: bRet := Base2InfoUnitShow(lMode); BASE_EMPLOYE: bRet := Base2InfoEmpShow(lMode); BASE_WARE: bRet := Base2InfoWareShow(lMode); BASE_DEPOT: bRet := Base2InfoDepotShow(lMode); BASE_FIXED_ADD: bRet := Base2InfoFixAddShow(lMode); BASE_FIXED_DEC: bRet := Base2InfoFixDecShow(lMode); BASE_WAGE_PROCEDURE: bRet := Base2InfoWageProcedureShow(lMode); BASE_WAGE_ITEM: bRet := Base2InfoWageItemShow(lMode); BASE_SUBJECT: begin lTabIndex := tabCtrl.TabIndex + 1; bRet := Base2InfoSubjectShow(lMode, lTabIndex, lRootID); end; end; if bRet then SaveDataSet(AdoSetBase2, False) else AdoSetBase2.Cancel;end;
 
避免使用 username、 password、use、date等保留字
 
保存的代码:function SaveDataSet(ADOSet1: TADODataSet; Cached: Boolean): Boolean;begin Result := True; if Cached = false then begin if (ADOSet1.State = dsEdit) or (ADOSet1.State = dsInsert) then ADOSet1.Post; end else begin if (ADOSet1.State = dsEdit) or (ADOSet1.State = dsInsert) then ADOSet1.Post; try ADOSet1.UpdateBatch; except Result := False; end; end;end;
 
Delphi世界qq群:23981160喜欢d的都来
 
问题:缺少更新或刷新的基本表消息:解决:表必须有主键操作:用企业管理器打开表,编辑,点击钥匙模样的图标将某个字段设置成主键
 
stlont你好,设了ID这主健,还是没用。那么如何判断这些哪个要设为主健呢?W.ID, W.TreeParent, W.UserCode, W.Name, W.ShortName, W.PinYin, W.Model, W.Spec,' + ' W.Area, W.Type, W.Unit, W.Unit2, W.Scale, W.Sort, W.BarCode, W.Pos_Price, W.Pos_Purch,' + ' W.ConstPrice, W.Price1, W.Price2, W.Price3, W.Price4, W.Up_Limit, W.Down_Limit, W.Memo, W.Use, W.Mode'
 
后退
顶部