Vb.net 当我在crystal report中插入一个字段时,';s该字段不显示在报告中的代码

Vb.net 当我在crystal report中插入一个字段时,';s该字段不显示在报告中的代码,vb.net,crystal-reports,Vb.net,Crystal Reports,这是打印命令上的代码 数据集与数据库连接成功 Try Dim rpt As New rptallergy2 Dim myConnection As SqlConnection Dim MyCommand1 As New SqlCommand() Dim myDA1 As New SqlDataAdapter() Dim myDS As New DataSet

这是打印命令上的代码 数据集与数据库连接成功

Try
            Dim rpt As New rptallergy2
            Dim myConnection As SqlConnection
            Dim MyCommand1 As New SqlCommand()
            Dim myDA1 As New SqlDataAdapter()
            Dim myDS As New DataSet
            myConnection = New SqlConnection(cs)

            MyCommand1.Connection = myConnection
            MyCommand1.CommandText = "SELECT RTRIM(patient.name) from patient  "
            MyCommand1.CommandType = CommandType.Text

            myDA1.SelectCommand = MyCommand1

            myDA1.Fill(myDS, "patient")

            rpt.SetDataSource(myDS)
            frmReport.CrystalReportViewer1.ReportSource = rpt
            frmReport.ShowDialog()
        Catch ex As Exception
            MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
        End Try

然后将
pName
字段与crystal reports上的字段进行匹配,这是Jonathan Willcock所说的。

这里有问题吗?此字段不会出现在报告中。SQL返回一个未命名字段,因为它取决于函数。您将需要使用别名,以匹配crystal report期望作为字段名称的名称。我使用了where语句,问题仍然存在
MyCommand1.CommandText = "SELECT RTRIM(patient.name) as pName from patient"