dds.Fill(ds,"tablename")由于我的是多表联合查询,报表里用的字段也是多个表的,这里如果只填一个表名,报表里其他表里的字段就找不到,提示登录失败
dds.Fill(ds,"tablename1")
dds.Fill(ds,"tablename2")
这样填充后是可以显示,但数据得到的就不是我联合查询后的数据了
直接这样dds.Fill(ds)写也不行!请高手们指教啊!!!!!!
dds.Fill(ds,"tablename1")
dds.Fill(ds,"tablename2")
这样填充后是可以显示,但数据得到的就不是我联合查询后的数据了
直接这样dds.Fill(ds)写也不行!请高手们指教啊!!!!!!
解决方案 »
- 怎么动态向RadioButtonList 添加项啊? 菜鸟苦等 2个小时了!谢谢大家
- 搭建过50人以上用户的WEB应用服务器的朋友进来帮帮忙!谢谢
- 探讨:Web开发除了ASP.NET还要掌握哪些技术?Web开发是否是未来开发的主流?
- http://txysoft.vicp.net/liuye/DefaultAdd.aspx网址的权限问题,急!!!
- 打包打包又是打包!!---为什么不能指定安装目录?[不是虚拟目录,而是根目录!]
- 有关配置authorization的问题。
- 请教大虾米为什么收不到邮件
- 想做一个按钮,控制在文本框中加入html语主言,不知如何下手,请教各们高手。
- 在设计水晶报表时, 用mouse 拖动field 到设计界面时, 有时字段的宽度会是很长的, 有时宽度又很小的, 这个东西是怎样设置的? 不用我每
- 在建立webservice的时候,Arraylist如何传递给webservice?
- 更改数据库问题,总有一个值更改不过来
- 关于验证控件
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://www.njpro.cn/20069/ShowPost.aspx
dds.Fill(ds,"tablename") 只添一个表就会报错。。
dds.Fill(ds,"tablename1")
dds.Fill(ds,"tablename2")
这样吧所有的表都填充了就可以显示,但是数据又不对,不是正确的数据
这样写的
sql="select a.* ,b.* from aa a left join bb b on a.id=b.id"
......
dds.Fill(ds,"aa")
//新建表结构
DataTable dt=new DataTable("clyfhzb");//表名字必须和你的xsd文件中一张表名一样
dt.Columns.Add("trq",System.Type.GetType("System.DateTime"));
dt.Columns.Add("ccph",System.Type.GetType("System.String"));
dt.Columns.Add("njs",System.Type.GetType("System.Int32"));
dt.Columns.Add("nyf",System.Type.GetType("System.Decimal"));
dt.Columns.Add("nmjyf",System.Type.GetType("System.Decimal"));
dss.Tables.Add(dt); //添加到数据集中
这个表结构和你xsd文件中的某张表一样,
<xs:element name="clyfhzb">
<xs:complexType>
<xs:sequence>
<xs:element name="trq" type="xs:dateTime" />
<xs:element name="ccph" type="xs:string" />
<xs:element name="njs" type="xs:int" />
<xs:element name="nyf" type="xs:decimal" />
<xs:element name="nmjyf" type="xs:decimal" />
</xs:sequence>
</xs:complexType>
</xs:element>然后添加数据:
//为数据集添加数据,
for(int i=0;i<this.ds.Tables["clyfhzb"].Rows.Count;i++) //this.ds.Tables["clyfhzb"]就是你连接查询的得到的ds,
{
DataRow dr=dt.NewRow();
dr["trq"]=ds.Tables["clyfhzb"].Rows[i]["tccsj"];
dr["ccph"]=ds.Tables["clyfhzb"].Rows[i]["ccph"];
dr["njs"]=ds.Tables["clyfhzb"].Rows[i]["nchjs"];
dr["nyf"]=ds.Tables["clyfhzb"].Rows[i]["yf"];
// if(System.Convert.ToInt32(dr["njs"].ToString())==0||System.Convert.ToDecimal(dr["nyf"].ToString())==0)
// {
// dr["nmjyf"]=0;
// }
// else
// {
dr["nmjyf"]=System.Convert.ToDecimal(dr["nyf"].ToString())/System.Convert.ToInt32(dr["njs"].ToString());
// }
dt.Rows.Add(dr);
}
我想会不会是你的结构不一样,或者表字段名称不一样引起错误的。
------------------------------------我想应该是的!如果你不想做,保证你的填入ds的表的格式和你xsd的格式一样就可以了。