关于要求输入密码的问题~~~谢谢~~

ahya 2005-08-29 02:10:01
小弟做好了报表数据查询是在报表中完成的。。
asp.net页面调用报表,只提供给参数就可以了,但是现在页面显示要求输入密码。,请问怎么结决
我没有用到数据集。。
ParameterFields paramFields=new ParameterFields();
ParameterField ParameterFieldsA= new ParameterField();
ParameterField ParameterFieldsB= new ParameterField();
ParameterField ParameterFieldsC= new ParameterField();
ParameterField ParameterFieldsD= new ParameterField();


ParameterDiscreteValue ParameterDiscreteValueA=new ParameterDiscreteValue();
ParameterDiscreteValue ParameterDiscreteValueB=new ParameterDiscreteValue();
ParameterDiscreteValue ParameterDiscreteValueC=new ParameterDiscreteValue();
ParameterDiscreteValue ParameterDiscreteValueD=new ParameterDiscreteValue();





ParameterFieldsA.ParameterFieldName="comID";
ParameterFieldsB.ParameterFieldName="Mantype";
ParameterFieldsC.ParameterFieldName="DateBgn";
ParameterFieldsD.ParameterFieldName="DateEnd";

ParameterDiscreteValueA.Value ="2";
ParameterDiscreteValueB.Value ="1";
ParameterDiscreteValueC.Value ="2004-1-1";
ParameterDiscreteValueD.Value ="2005-7-1";


ParameterFieldsA.CurrentValues.Add(ParameterDiscreteValueA);
ParameterFieldsB.CurrentValues.Add(ParameterDiscreteValueB);
ParameterFieldsC.CurrentValues.Add(ParameterDiscreteValueC);
ParameterFieldsD.CurrentValues.Add(ParameterDiscreteValueD);





paramFields.Add(ParameterFieldsA);
paramFields.Add(ParameterFieldsB);
paramFields.Add(ParameterFieldsC);
paramFields.Add(ParameterFieldsD);




CrystalReportViewer1.ParameterFieldInfo=paramFields;
CrystalReportViewer1.ReportSource=Server.MapPath("hrtl.rpt");
CrystalReportViewer1.DataBind();
...全文
319 12 打赏 收藏 转发到动态 举报
写回复
用AI写文章
12 条回复
切换为时间正序
请发表友善的回复…
发表回复
lyb_abiandbel 2005-09-06
  • 打赏
  • 举报
回复
兄弟我劝你还是不要用odbc和水晶报表连接,还是用.net
odbc的连接信息肯定不是这样的。
lyb_abiandbel 2005-09-06
  • 打赏
  • 举报
回复
如果你用的是水晶报表的推模式,一般不用设置登陆信息,但是要这样写:obj.SetDataSource(this.ds.Tables["tablename"]);如果你写成了obj.SetDataSource(this.ds)就会有登陆框的。

如果你用的是水晶报表的拉模式,你就一定要写上登陆信息:

crReportDocument = new OracleReport();

//Set the crConnectionInfo with the current values stored in the report
crConnectionInfo = crReportDocument.Database.Tables[0].LogOnInfo.ConnectionInfo;

/* Populate the ConnectionInfo Objects Properties with the appropriate values for
the ServerName, User ID, Password and DatabaseName. However, since Oracle
works on Schemas, Crystal Reports does not recognize or store a DatabaseName.
Therefore, the DatabaseName property must be set to a BLANK string. */
crConnectionInfo.DatabaseName = "";
crConnectionInfo.ServerName = "Your Server Name";
crConnectionInfo.UserID = "Your User ID";
crConnectionInfo.Password = "Your Password";

//Set the CrDatabase Object to the Report's Database
crDatabase = crReportDocument.Database;

//Set the CrTables object to the Tables collection of the Report's dDtabase
crTables = crDatabase.Tables;

//Loop through each Table object in the Tables collection and apply the logon info
//specified ealier. Note this sample only has one table so the loop will only execute once
foreach (Table crTable in crTables)
{
crTableLogOnInfo = crTable.LogOnInfo;
crTableLogOnInfo.ConnectionInfo = crConnectionInfo;
crTable.ApplyLogOnInfo (crTableLogOnInfo);

// if you wish to change the schema name as well, you will need to set Location property as follows:
// crTable.Location = "<new schema name>." + crTable.Name;
}

//Set the ReportSource of the CrystalReportViewer to the strongly typed Report included in the project
crystalReportViewer1.ReportSource = crReportDocument;

还有一点要注意:
如果你用到了子报表,一定要处理:

//Go through each sections in the main report and identify the subreport by name
crSections = crReportDocument.ReportDefinition.Sections;

foreach(Section crSection in crSections)
{
crReportObjects = crSection.ReportObjects;
//loop through all the report objects to find all the subreports
foreach(ReportObject crReportObject in crReportObjects)
{
if (crReportObject.Kind == ReportObjectKind.SubreportObject)
{
//you will need to typecast the reportobject to a subreport
//object once you find it
crSubreportObject = (SubreportObject)crReportObject;

//open the subreport object
crSubReportDoc = crSubreportObject.OpenSubreport(crSubreportObject.SubreportName);
//Once the correct subreport has been located pass it the
//appropriate dataset
if(crSubReportDoc.Name == "FirstSub")
{
//crSubReportDoc.Database.Tables[0].SetDataSource(ds);
crSubReportDoc.SetDataSource(ds);
}
}
}
}
crystalReportViewer1.ReportSource = crReportDocument;

同样crSubReportDoc.SetDataSource(ds);改为:crSubReportDoc.SetDataSource(ds.Tables["tablename"]);


http://blog.csdn.net/lyb_abiandbel/archive/2005/09/05/471660.aspx
TonyZeus 2005-09-05
  • 打赏
  • 举报
回复
ODBC 确实是不保存密码的,设计成这样的~
ahya 2005-08-31
  • 打赏
  • 举报
回复
设计好的阿,我用水晶设计器预览什么的都是正常的..
就是那个odbc里面不让保存密码。。。不知道怎么回事。。。。
xwdd129 2005-08-31
  • 打赏
  • 举报
回复
提示错误:登录失败。详细资料: IM002:[Microsoft][ODBC 驱动程序管理器] 未发现数据源名称
---------------------------------

看这个错误是没有设置好ODBC数据源,进入控制面板-->管理工具-->数据源 (ODBC),添加用户DSN
ahya 2005-08-31
  • 打赏
  • 举报
回复
ReportDocument oRpt = new ReportDocument();
TableLogOnInfo LInfo = new TableLogOnInfo();
LInfo.ConnectionInfo.ServerName = "CenterDB";
LInfo.ConnectionInfo.DatabaseName = "CTDB";
LInfo.ConnectionInfo.UserID = "zona";
LInfo.ConnectionInfo.Password = "zona";
oRpt.Load("E:\\report_zona\\ahya\\rpttest\\test6.rpt");
oRpt.Database .Tables [0].ApplyLogOnInfo (LInfo);
//oRpt.Load("test6.rpt");
CrystalReportViewer1.ReportSource=oRpt;

提示错误:登录失败。详细资料: IM002:[Microsoft][ODBC 驱动程序管理器] 未发现数据源名称并且未指定默认驱动程序文件 C:\DOCUME~1\COCA78\ASPNET\LOCALS~1\Temp\{764C1377-7C30-4B6F-A80A-5CFDA1014912}.rpt 内出错:无法连接:错误的登录参数。

ahya 2005-08-31
  • 打赏
  • 举报
回复
是这么写么?谢谢帮忙~ReportDocument要怎么设定么?
------------
int i;

ReportDocument oRpt = new ReportDocument();
TableLogOnInfo LInfo = new TableLogOnInfo();
LInfo.ConnectionInfo.ServerName = "CenterDB";
LInfo.ConnectionInfo.DatabaseName = "CTDB";
LInfo.ConnectionInfo.UserID = "zona";
LInfo.ConnectionInfo.Password = "zona";
for(i=0;i<= oRpt.Database.Tables.Count-1;i++)
{
oRpt.Database.Tables[i].ApplyLogOnInfo(LInfo);
}




ParameterFields paramFields=new ParameterFields();
ParameterField ParameterFieldsA= new ParameterField();
ParameterDiscreteValue ParameterDiscreteValueA=new ParameterDiscreteValue();
ParameterFieldsA.ParameterFieldName="a";
ParameterDiscreteValueA.Value =TextBox1.Text;
ParameterFieldsA.CurrentValues.Add(ParameterDiscreteValueA);
paramFields.Add(ParameterFieldsA);
CrystalReportViewer1.ParameterFieldInfo=paramFields;
CrystalReportViewer1.ReportSource=Server.MapPath("test6.rpt");
kolleen 2005-08-30
  • 打赏
  • 举报
回复
将设置好的logOnInfo赋值到每张表,如
ReportDocument oRpt = new ReportDocument();
TableLogOnInfo logOnInfo = new TableLogOnInfo()
for(i=0;i<= oRpt.Database.Tables.Count-1;i++)
{
oRpt.Database.Tables[i].ApplyLogOnInfo(logOnInfo);
}

另外将CrystalReportViewer1.DataBind();这句去掉
TonyZeus 2005-08-30
  • 打赏
  • 举报
回复
你需要把你的TableLogOnInfo信息给你的水晶报表中的表啊
ahya 2005-08-29
  • 打赏
  • 举报
回复
那位兄弟姐妹帮下哈~~
ahya 2005-08-29
  • 打赏
  • 举报
回复
TableLogOnInfo LInfo = new TableLogOnInfo();
LInfo.ConnectionInfo.ServerName = "CenterDB";
LInfo.ConnectionInfo.DatabaseName = "CTDB";
LInfo.ConnectionInfo.UserID = "znna";
LInfo.ConnectionInfo.Password = "znna";
是这么写么?没用阿。。
wen98091 2005-08-29
  • 打赏
  • 举报
回复
CrystalReportViewer1.LogonInfo
把它写全就好了.
这是登录数据库信息.

4,818

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 图表区
社区管理员
  • 图表区社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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