Delphi 5&Crystal XI Rel。 2(RDC)如何?

问题描述 投票:0回答:3

我正在尝试使用class from JosephStyons,但在应该设置“用户ID”的行上确实收到“无效索引”错误。

FRpt.Database.Tables[i].ConnectionProperties.Item['User ID'] := edUserName.Text;

这是我的环境:

WinXP Sp3,Crystal Reports Developer XI Rel.2 SP4,Delphi 5更新包1

非常感谢任何帮助或想法!

Thx,莱因哈德

delphi crystal-reports
3个回答
1
投票

您的值for [i]可能是罪魁祸首...我不确定,但是我相信第一个表将是Table[1]而不是人们期望的Table[0]

我更改了循环以使用:

CrTables := CrDatabase.Tables;
for crTableObj in crTables do

您可以尝试使用上面所示的for循环或以1而不是0开头来逐步浏览表。

我希望这会有所帮助。


0
投票

在该行上放置一个断点,然后使用评估/修改。如果尝试无效的操作,它将返回错误。

  1. 检查FRpt.Database.Tables[i],看看它是否对i的最小值和最大值有效。如果Tables是一个数组,避免这种情况的一种方法是使用...Low(Tables) to High(Tables)

  2. 如果您的表确定,请检查FRpt.Database.Tables[i].ConnectionProperties.Item['User ID']并查看其是否有效。可能是Item getter不喜欢“用户ID”中嵌入的空间。有些产品需要用特殊字符(如“ [用户ID]”)包围,而另一些产品需要用下划线代替,如“ User_ID”


0
投票

您还要设置密码,服务器名和数据库名吗?

过程TReports.LogonToDBTables(cReport:CrystalDecisions.CrystalReports.Engine.ReportDocument;ConnInfo:ConnectionInfo);变种CrDataBase:数据库;CrTables:表格;CrTableObj:TObject;CrTable:表格;CrTableLogonInfo:TableLogonInfo;iSubReportIndex:smallint;开始CrDataBase:= CReport.Database;CrTables:= CrDatabase.Tables;cReport.DataSourceConnections [0] .IntegratedSecurity:= False;在crTables中为crTableObj做开始crTable:= CrystalDecisions.CrystalReports.Engine.Table(crTableObj);crTableLogonInfo:= crTable.LogOnInfo;crTableLogonInfo.ConnectionInfo:= ConnInfo;crTable.ApplyLogOnInfo(crTableLogonInfo);结束;结束;函数TReports.GetConnectionInfo():ConnectionInfo;变种cTemp:ConnectionInfo;开始cTemp:= ConnectionInfo.Create();cTemp.AllowCustomConnection:= True;cTemp.ServerName:= GetServerName();cTemp.DatabaseName:= GetDBName();cTemp.UserID:= GetDBUserID();cTemp.Password:= GetDBPassword();结果:= cTemp;结束;
© www.soinside.com 2019 - 2024. All rights reserved.