单击显示工具栏上的任何按钮时,Crystal Report询问参数? [英] Crystal Report Asking Parameter on click on any button of display toolbar?
问题描述
on First Display报告显示正常,但是当我点击显示栏的任何一个按钮时,它开始询问参数。(报告是使用sql Store程序设计的,需要很少的参数,但我想在DataTable中使用相同的参数和设置为DataSource)请提供下面给出的解决方案代码
private void LoadImage(DataRow objDataRow,string strImageField,string FilePath)
{
尝试
{
System.IO.FileStream fs = new System.IO.FileStream(FilePath,System.IO.FileMode.Open,System .IO.FileAccess.Read);
byte [] Image = new byte [fs.Length];
fs.Read(Image,0,Convert.ToInt32(fs) .Length));
fs.Close();
objDataRow [strImageField] =图片;
}
catch(exception ex)
{
Response.Write(+ ex.Message +);
}
}
public void ShowRpt2()
{
ViewState [Load] =;
string RptCon = System.Configuration.ConfigurationManager.AppSettings [RptCon ];
string [] SplitedRptCon = RptCon.Split(',');
string ServerName = SplitedRptCon [0];
string UserName = SplitedRptCon [1];
string Password = SplitedRptCon [2];
DataTable dt =(DataTable)ViewState [dt2];
if(dt.Rows.Count> 0)
{
for(int index = 0; index< dt.Rows.Count; index ++)
{
if(dt.Rows [index] [ItemImage]。ToString()!=)
{
string s = this.Server.MapPath(dt.Rows [index] [ItemImage]。ToString());
if(System.IO.File.Exists(s))
{
LoadImage(dt.Rows [index],Img,s);
}
} < br $>
}
ReportDocument rptDoc = new ReportDocument();
string path = Server.MapPath(〜/ Cr / CrSupplierTranHistory.rpt);
rptDoc.Load(路径);
ConnectionInfo connectionInfo = new ConnectionInfo();
TableLogOnInfo crTableLogonInf o = new TableLogOnInfo();
connectionInfo.ServerName = ServerName;
connectionInfo.DatabaseName = EsSunkris;
connectionInfo.UserID = UserName;
connectionInfo.Password =密码;
connectionInfo.IntegratedSecurity = false;
表crTables = rptDoc.Database.Tables;
foreach(CRTables中的CrystalDecisions.CrystalReports.Engine.Table CrTable)
{
crTableLogonInfo = CrTable.LogOnInfo;
crTableLogonInfo.ConnectionInfo = connectionInfo;
CrTable.ApplyLogOnInfo(crTableLogonInfo);
}
rptDoc.SetDataSource(dt);
rptDoc.SetParameterValue(@ SRoomCode,1 );
rptDoc.SetParameterValue(@ ToDate,2014/3/14);
rptDoc.SetParameterValue(@ AccCode,177);
rptDoc.SetParameterValue(@ ItemCode,0);
rptDoc.VerifyDatabase();
//rptDoc.PrintToPrinter(1,true,1, 1);
RptViewer.ReportSource = rptDoc;
/ / RptViewer.RefreshReport();
}
else
{
lblMsg.Text =没有找到打印记录;
}
}
确保你的代码没有遗漏任何东西。
C#Crystal Reports字符串参数 [ ^ ]
也查看过去的答案
处理Crystal Reports中的提示消息 [ ^ ]
要禁用提示,
如何禁用Crystal Report的参数提示 [ ^ ]
禁用Crystal Reports for Visual Studio中的参数提示对话框 [ ^ ]
要删除按钮,
如何在Crystal Report中禁用按钮 [ ^ ]
on First Display report is showing fine but when i click on any of the button of Display bar it start asking Parameter.(Report is designed using sql Store procedure which requires few parameter but i want to use the same parameter in DataTable and set as DataSource)Please provide me solution code given below
private void LoadImage(DataRow objDataRow, string strImageField, string FilePath)
{
try
{
System.IO.FileStream fs = new System.IO.FileStream(FilePath, System.IO.FileMode.Open, System.IO.FileAccess.Read);
byte[] Image = new byte[fs.Length];
fs.Read(Image, 0, Convert.ToInt32(fs.Length));
fs.Close();
objDataRow[strImageField] = Image;
}
catch (Exception ex)
{
Response.Write("" + ex.Message + "");
}
}
public void ShowRpt2()
{
ViewState["Load"] = "";
string RptCon = System.Configuration.ConfigurationManager.AppSettings["RptCon"];
string[] SplitedRptCon = RptCon.Split(',');
string ServerName = SplitedRptCon[0];
string UserName = SplitedRptCon[1];
string Password = SplitedRptCon[2];
DataTable dt = (DataTable)ViewState["dt2"];
if (dt.Rows.Count > 0)
{
for (int index = 0; index < dt.Rows.Count; index++)
{
if (dt.Rows[index]["ItemImage"].ToString() != "")
{
string s = this.Server.MapPath(dt.Rows[index]["ItemImage"].ToString());
if (System.IO.File.Exists(s))
{
LoadImage(dt.Rows[index], "Img", s);
}
}
}
ReportDocument rptDoc = new ReportDocument();
string path = Server.MapPath("~/Cr/CrSupplierTranHistory.rpt");
rptDoc.Load(path);
ConnectionInfo connectionInfo = new ConnectionInfo();
TableLogOnInfo crTableLogonInfo = new TableLogOnInfo();
connectionInfo.ServerName = ServerName;
connectionInfo.DatabaseName = "EsSunkris";
connectionInfo.UserID = UserName;
connectionInfo.Password = Password;
connectionInfo.IntegratedSecurity = false;
Tables crTables = rptDoc.Database.Tables;
foreach (CrystalDecisions.CrystalReports.Engine.Table CrTable in crTables)
{
crTableLogonInfo = CrTable.LogOnInfo;
crTableLogonInfo.ConnectionInfo = connectionInfo;
CrTable.ApplyLogOnInfo(crTableLogonInfo);
}
rptDoc.SetDataSource(dt);
rptDoc.SetParameterValue("@SRoomCode", 1);
rptDoc.SetParameterValue("@ToDate", "2014/3/14");
rptDoc.SetParameterValue("@AccCode", 177);
rptDoc.SetParameterValue("@ItemCode", 0);
rptDoc.VerifyDatabase();
//rptDoc.PrintToPrinter(1, true, 1, 1);
RptViewer.ReportSource = rptDoc;
// RptViewer.RefreshReport();
}
else
{
lblMsg.Text = "No Record found for print";
}
}
Make sure your code not missing anything.
C# Crystal Reports String parameter[^]
also check this past answer
Handling Prompt messages in Crystal Reports[^]
To disable prompt,
How To Disable the Parameter Prompt for Crystal Report[^]
Disabling Parameter Prompt Dialog Box in Crystal Reports For Visual Studio[^]
To remove button(s),
How To Disable Button(s) In Crystal Report[^]
这篇关于单击显示工具栏上的任何按钮时,Crystal Report询问参数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!