Delphi 2007 中的水晶报表
我有:
Delphi 2007
Crystal 11
Delphi 7 版本的 Crystal VCL 组件(我知道的最新版本,它在 D2007 中编译得很好)
一个非常简单的测试 Crystal 报告,用 Crystal 11 编写,它只是将表格转储到屏幕上(没有选择标准,没有公式,只是直接数据)
我尝试过
创建了一个新的 VCL 表单应用程序
将 TCrpe 组件放在表单上将
“ReportName”属性设置为我的测试报告。
我在表单上放置了一个按钮,并在其后面放置了一行:
Crpe1.Execute
如果报表的“使用报表保存数据”选项已打开,则此操作正常。
如果我关闭该选项,那么我需要提供登录凭据。
使用此代码(一百万年前在 Delphi 5 中运行良好):
procedure TForm1.BitBtn1Click(Sender: TObject);
var
logonItem: integer;
begin
Crpe1.LogOnServer.Clear;
logonItem := Crpe1.LogOnServer.Add('MYSERVER.MYDOMAIN.COM');
Crpe1.LogonServer[logonItem].UserID := 'USERNAME';
Crpe1.LogOnServer[logonItem].Password := 'PASSWORD';
Crpe1.LogOnServer[logonItem].DatabaseName := 'MYDATABASE';
Crpe1.Execute;
end;
我收到此错误:
---------------------------
Project2
---------------------------
Error:536 Error in File C:\REPORT.RPT:
Unable to connect: incorrect log on parameters.
Execute <PEStartPrintJob>.
---------------------------
OK
---------------------------
我做错了什么?如何向 Delphi 中的 Crystal VCL 组件提供登录凭据?我当前的解决方法是相当难看,而且我有很多遗留代码需要转换。如果我能以简单的方式使用 VCL 组件,那就太好了。
I have:
Delphi 2007
Crystal 11
The Delphi 7 version of the Crystal VCL component (latest one I'm aware of, and it compiles fine in D2007)
A very simple test Crystal report, written in Crystal 11, which just dumps a table onto the screen (no selection criteria, no formulas, just straight data)
I tried
Created a new VCL forms app
Dropped the TCrpe component on the form
Set the "ReportName" property to my test report.
I dropped a button on the form, and behind it placed one line:
Crpe1.Execute
If the report has the "Save Data With Report" option turned on, then this works fine.
If I turn that option off, then I need to provide login credentials.
Using this code (which worked fine in Delphi 5 a million years ago):
procedure TForm1.BitBtn1Click(Sender: TObject);
var
logonItem: integer;
begin
Crpe1.LogOnServer.Clear;
logonItem := Crpe1.LogOnServer.Add('MYSERVER.MYDOMAIN.COM');
Crpe1.LogonServer[logonItem].UserID := 'USERNAME';
Crpe1.LogOnServer[logonItem].Password := 'PASSWORD';
Crpe1.LogOnServer[logonItem].DatabaseName := 'MYDATABASE';
Crpe1.Execute;
end;
I get this error:
---------------------------
Project2
---------------------------
Error:536 Error in File C:\REPORT.RPT:
Unable to connect: incorrect log on parameters.
Execute <PEStartPrintJob>.
---------------------------
OK
---------------------------
What am I doing wrong? How can I provide login credentials to the Crystal VCL component in Delphi? My current workaround is pretty ugly, and I have a lot of legacy code to convert. It would be really nice if I could use the VCL component in a straightforward way.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我在Delphi 6中使用VCL,效果很好。但我不使用 LogOnServer 属性,而是使用 LogOnInfo。
这适用于任何报告以及包含子报告的报告(因为这些报告也需要提供凭据):
I use the VCL in Delphi 6, works great. But I don't use the LogOnServer property, I use the LogOnInfo.
This works for any report, and reports that contain subreports (as these need the credentials supplying as well):
以下是一些使用 VCL 组件的旧“遗留”代码:
不久前,我读到 Crystal VCL 组件正在“废弃”。从那时起,我已迁移到 Active X RDC 组件。不过,它需要在您的目标计算机上安装 Active X。
Here is some old "legacy" code which uses the VCL component:
Some time ago I had read the Crystal VCL component was being "sunsetted". Since then I have migrated to the Active X RDC component. It will require the Active X to be installed on your target computers though.