水晶报表(Crystal Report)中带参数的

NewSun99 2003-12-12 02:43:57
水晶报表图形化设计不能产生Where语句吗(我不是说关联)?
比如:
select * from Sysobjects where id = 1
再如:
我想实现参数,
比如(例子)
select * from Sysobjects where id = {?@ID}

可是怎么通不过呢?
正确的用法应该怎么样呢?
...全文
103 12 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
12 条回复
切换为时间正序
请发表友善的回复…
发表回复
雪狼1234567 2003-12-13
  • 打赏
  • 举报
回复
参数是你很多传进sql语句,然后得到数据后再打印出来,效果一样:
CrpRepairRpt crp = new CrpRepairRpt();
System.Data.DataSet dt = new System.Data.DataSet();
System.Data.SqlClient.SqlConnection conn = new System.Data.SqlClient.SqlConnection("server=localhost;database =hos;uid=sa;pwd=");
conn.Open();
System.Data.SqlClient.SqlDataAdapter da = new System.Data.SqlClient.SqlDataAdapter("select * from temp where id='1'",conn);
//参数在上面的sql语句中下,如
da.Fill(dt,"temp");
crp.SetDataSource(dt);
this.crystalReportViewer1.ReportSource = crp;
lanbaibai 2003-12-13
  • 打赏
  • 举报
回复
用push模式就可以解决你的问题,先用sql语句过滤,在传入水晶报表。
在 Web 上打印水晶报表的四种方法

请参见:报表分发

如果想使用户能够打印在 Web 上访问的整个多页报表,您有下列选项:

1、使用Web 窗体 Viewer 工具栏上的“打印”按钮将报表导出为 PDF。

2、使用Web 窗体 Viewer 工具栏上的“导出”按钮,导出报表为可以由客户端的现有应用程序打印的格式。

3、使用PrintToPrinter 方法从服务器打印报表。

4、将报表作为一个连续的页提供以通过 Internet Explorer 浏览器在客户端启用打印。

如果用户无权访问打印导出的报表所需的应用程序,并且服务器端打印存在安全性或访问权限问题,您可能需要使用户能够从他们的浏览器打印报表。此方法将整个报表作为一个连续的页显示在 Web 窗体 Viewer 控件中,因而能够使用浏览器的打印功能。

在应用程序中,可以在现有 Web 窗体 Viewer 旁边添加一个按钮,该按钮可以将客户端重定向到新的、在浏览器中将整个报表显示为一个连续页的 Web 窗体 Viewer。可以对第二个窗体上的查看器进行格式化,以便禁用组树和工具栏,并将查看器的 SeparatePages 属性设置为 False。

注意 这种打印方法有一个局限,即无法控制页眉、页脚和分页符的定位。
crReportDocument = New Income_Statement()
CrystalReportViewer1.ReportSource = crReportDocument
CrystalReportViewer1.SeparatePages = False
CrystalReportViewer1.DisplayGroupTree = False
CrystalReportViewer1.DisplayToolbar = False

dotnba 2003-12-13
  • 打赏
  • 举报
回复
//将CreateImage修改成这样看看

private void CreateImage()
{
int iWidth = (iCols + 2) * iRectSize;
int iHeight = (iRows + 2) * iRectSize;
memoryImage = new Bitmap(iWidth,iHeight);
Graphics pGraphic = Graphics.FromImage(memoryImage);
SolidBrush brushWhite = new SolidBrush(Color.White);
SolidBrush brushBlack = new SolidBrush(Color.Black);
Pen blackpen = new Pen(Color.Black,2);
FontFamily FF = new FontFamily( GenericFontFamilies.Serif ) ;
Font MyFont = new Font( FF, 9 ) ;

for(int i = 0;i < iCols;i ++)
{
for(int j = 0;j < iRows;j ++)
{
pGraphic.DrawRectangle(blackpen, (2 + i) * iRectSize,(2 + j) * iRectSize,iRectSize,iRectSize);
pGraphic.DrawString("Test",MyFont,brushBlack,new Rectangle((2 + i) * iRectSize + 2,(2 + j) * iRectSize + 2,iRectSize - 4,iRectSize));
}
}
brushWhite.Dispose();
blackpen.Dispose();
brushBlack.Dispose();
//
}
NewSun99 2003-12-13
  • 打赏
  • 举报
回复
To snof(雪狼):那还是说直接在设计器里不能实现啊。
可能是我刚用的原因,有的不熟悉。我觉得水晶报表不太爽啊。他的导出功能强外,别的我没什么感觉。
我的是集成在9.1.5 For .Net 2003。
比如:报表控件太缺乏,并且不能写公式。比如线条的粗细。
控件间没有等距等格式。
NewSun99 2003-12-12
  • 打赏
  • 举报
回复
谁能教我怎么把这个Grid打印出来啊
NewSun99 2003-12-12
  • 打赏
  • 举报
回复
using System;
using System.Drawing;
using System.ComponentModel;
using System.Windows.Forms;
using System.Drawing.Printing;
using System.Runtime.InteropServices;
namespace Sample
{
/// <summary>
/// Form1 的摘要说明。
/// </summary>
public class frmDemo : System.Windows.Forms.Form
{
private System.ComponentModel.IContainer components = null;
private int iCols = 10 ,iRows = 10;
private System.Windows.Forms.Panel panel1;
private const int iRectSize = 40;
private System.Windows.Forms.Button btnPrint;
private System.Windows.Forms.Button btnCancel;
public frmDemo()
{
InitializeComponent();
}
protected override void Dispose( bool disposing )
{
if( disposing )
{
if (components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}
private void InitializeComponent()
{
this.panel1 = new System.Windows.Forms.Panel();
this.btnPrint = new System.Windows.Forms.Button();
this.btnCancel = new System.Windows.Forms.Button();
this.SuspendLayout();
//
// panel1
//
this.panel1.AutoScroll = true;
this.panel1.Location = new System.Drawing.Point(8, 8);
this.panel1.Name = "panel1";
this.panel1.Size = new System.Drawing.Size(336, 280);
this.panel1.TabIndex = 0;
this.panel1.Paint += new System.Windows.Forms.PaintEventHandler(this.panel1_OnPaint);
//
// btnPrint
//
this.btnPrint.Location = new System.Drawing.Point(360, 216);
this.btnPrint.Name = "btnPrint";
this.btnPrint.TabIndex = 1;
this.btnPrint.Text = "&Print";
this.btnPrint.Click += new System.EventHandler(this.btnPrint_Click);
//
// btnCancel
//
this.btnCancel.Location = new System.Drawing.Point(360, 256);
this.btnCancel.Name = "btnCancel";
this.btnCancel.TabIndex = 2;
this.btnCancel.Text = "&Cancel";
this.btnCancel.Click += new System.EventHandler(this.btnCancel_Click);
//
// frmDemo
//
this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
this.ClientSize = new System.Drawing.Size(464, 301);
this.Controls.Add(this.btnCancel);
this.Controls.Add(this.btnPrint);
this.Controls.Add(this.panel1);
this.Name = "frmDemo";
this.Text = "Draw Grids And Print All";
this.Load += new System.EventHandler(this.frmDemo_Load);
this.ResumeLayout(false);

}
private Bitmap memoryImage;
private System.Windows.Forms.Label lblPos;
private void panel1_OnPaint(object sender, System.Windows.Forms.PaintEventArgs e)
{
//Draw Grid
Graphics pGraphic= e.Graphics;
DrawGrid(pGraphic);
}
private void frmDemo_Load(object sender, System.EventArgs e)
{
//To Make panel1 Have ScrollBar.
lblPos = new Label();
lblPos.Left = (iCols + 2) * iRectSize;
lblPos.Top = (iRows + 2) * iRectSize;
panel1.Controls.Add(lblPos);
}

private void btnCancel_Click(object sender, System.EventArgs e)
{
//Close Form
this.Close();
}
private void CreateImage()
{
//My original idea is to draw grid on panel.But ...

int iWidth = (iCols + 2) * iRectSize;
int iHeight = (iRows + 2) * iRectSize;
Graphics pGraphic = panel1.CreateGraphics();
memoryImage = new Bitmap(iWidth,iHeight,pGraphic);
DrawGrid(pGraphic);

}
private void pd_PrintPage(object sender,PrintPageEventArgs ev)
{
ev.Graphics.DrawImage(memoryImage, 0, 0);
}

private void btnPrint_Click(object sender, System.EventArgs e)
{
PrintDocument pd = new PrintDocument();

CreateImage();
pd.PrintPage += new PrintPageEventHandler(pd_PrintPage);
pd.OriginAtMargins = true;
pd.DocumentName = "Grid On Panel";
PrintPreviewDialog pDialog = new PrintPreviewDialog ();
pDialog.Document = pd;
pDialog.ShowDialog();
pDialog.Dispose();
memoryImage.Dispose();
}
private void DrawGrid(Graphics pGraphic)
{
SolidBrush brushWhite = new SolidBrush(Color.White);
Pen blackpen = new Pen(Color.Black,2);
for(int i = 0;i < iCols;i ++)
{
for(int j = 0;j < iRows;j ++)
{
pGraphic.DrawRectangle(blackpen, panel1.AutoScrollPosition.X + (1 + i) * iRectSize, panel1.AutoScrollPosition.Y + (1 + j) * iRectSize,iRectSize,iRectSize);
}
}
brushWhite.Dispose();
blackpen.Dispose();
}
}
}
dotnba 2003-12-12
  • 打赏
  • 举报
回复
顶啊
NewSun99 2003-12-12
  • 打赏
  • 举报
回复
有参数这样可以减少传回的记录数啊
总不至于全都到前台来过滤吧?我的是WINFORM
NewSun99 2003-12-12
  • 打赏
  • 举报
回复
Soking(方呈怡心)
传递参数我知道怎么在编程传递,也知道在Crystal里如何定义
但是该参数不能成为我SQL的一部分吗?
Soking 2003-12-12
  • 打赏
  • 举报
回复
Crystal Button有一个参数字段,你需要在crystal 设计器中定义,然后编程传递参数
Soking 2003-12-12
  • 打赏
  • 举报
回复
Crystal Button有一个参数字段,你需要在crystal 设计器中定义,然后变程传递参数
yan1617 2003-12-12
  • 打赏
  • 举报
回复
不理解/不懂,帮你up一下
平日学习总结. 纯手工编辑啊!! 谢谢支持! -------------- 一: 前期准备工作  Crystal Report 2008  JDBC 相关jar包 --- mysql-connector-java-5.1.22-bin.jar(MySQL) Jar包下载: mysql-connector-java-5.1.22-bin.jar (见附件) JAR包添加: 1. 把JAR包放在水晶报表CrystalReport的目录下面 C:\Program Files\Business Objects\Common\4\java\lib\external 2. 然后找到 JAR包的配置文件CRConfig.xml C:\Program Files\Business Objects\Common\4\java\CRConfig.xml 3. 打开CRConfig.xml 在添加 C:\Program Files\Business Objects\Common\4.0\java/lib/external/mysql-connector-java-5.1.22-bin.jar; C:\Program Files\Business Objects\Common\4.0\java/lib/crlovmanifest.jar; C:\Program Files\Business Objects\Common\4.0\java/lib/CRLOVExternal.jar; C:\Program Files\Business Objects\Common\4.0\java/lib/CRDBJDBCServer.jar; C:\Program Files\Business Objects\Common\4.0\java/lib/CRDBXMLServer.jar; C:\Program Files\Business Objects\Common\4.0\java/lib/CRDBJavaBeansServer.jar; C:\Program Files\Business Objects\Common\4.0\java/lib/external/CRDBXMLExternal.jar; C:\Program Files\Business Objects\Common\4.0\java/lib/external/log4j.jar; C:\Program Files\Business Objects\Common\4.0\java/lib/CRDBSForceServer.jar; C:\Program Files\Business Objects\Common\4.0\java/lib/external/CRDBSForceExternal.jar;${CLASSPATH} 4. 更改水晶报表的JDK环境 <!--C:\Program Files\Business Objects\javasdk\bin--> C:\Program Files\Java\jdk1.6.0_06\bin

111,097

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • AIGC Browser
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧