具有两个或多个表的水晶报表 [英] Crystal report with Two or More Tables

查看:72
本文介绍了具有两个或多个表的水晶报表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

亲爱的所有人,

我尝试使用两个表进行报告,但是遇到了问题.我有两个表Bills和Sales.

Bills是一个主要的表,销售带有详细信息.当我使用单个表运行Crystal Reports Bills时,它运行正常,但是当我添加第二个表Sales的字段时,该报告什么也不显示.

这意味着它没有相互连接.但是如果我在SQL Query中输入相同的命令,它将可以正常运行.它显示了账单和销售的完整数据.

如果您看到下面提到的代码,则当我从报告页面中删除Sales Dbf字段时,但是当我添加Sales Dbf字段不显示错误时,它将正常运行.请提供有关错误的指南.

Dear all,

I try to make a report with using two tables but facing a problem. I have a two table Bills and Sales.

Bills is a master Table and sales takes a detail infromation. When I run Crystal report with a single table Bills it running Ok but when I add the field of second table Sales the report showing nothing.

It mean it is not connecting with one another.But same command if I put in SQL Query it will run ok. It shows complete data of Bills and sales.

If you see the under mention code it will run ok when i remove Sales Dbf field from the report page but when I add Sales Dbf field not showing error. Kindly guide about the mistake.

Option Strict On
Option Explicit On
Imports System.Data
Imports System.Data.SqlClient
Imports System.Drawing
Imports CrystalDecisions.CrystalReports.Engine
Public Class report
    Dim cryret As New ReportDocument
    Private Sub CrystalReportViewer1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CrystalReportViewer1.Load
        Dim rpt As New Invprt
        Dim myConnection As SqlConnection
        Dim MyCommand As New SqlCommand()
        Dim myDA As New SqlDataAdapter()
        Dim myDS As New Billing   'The DataSet you created.

        Try
            myConnection = New SqlConnection("Data Source=.\SQLEXPRESS;AttachDbFilename=F:\jatin\sale\jatin_Data.MDF;Integrated Security=True;Connect Timeout=30;User Instance=True")
            MyCommand.Connection = myConnection

            MyCommand.CommandText = "SELECT bills.docno" & _
          ", bills.glc, bills.tc,sales.qty  FROM BILLS INNER JOIN sales ON bills.tc = sales.tc and bills.docno=sales.docno order by bills.tc,bills.docno"

            MyCommand.CommandType = CommandType.Text
            myDA.SelectCommand = MyCommand

            myDA.Fill(myDS, "BILLS")
            rpt.SetDataSource(myDS)
            CrystalReportViewer1.ReportSource = rpt

        Catch Excep As Exception
            MessageBox.Show(Excep.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
        End Try
    End Sub
End Class

推荐答案


因此请尝试使用xsdschema文件来解决该问题.
ok seems u ve changed field names of sales table . so crystal report not recognising the columns

so please try to use xsdschema file to get it solved.


这篇关于具有两个或多个表的水晶报表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆