0
這是在打印命令 代碼與數據庫連接成功當我插入域到水晶報表,這就是現場沒有出現在報告中的代碼
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
這裏有問題嗎? –
該字段不會出現在報告中 –
您的SQL返回一個未命名的字段,因爲它取決於該函數。您需要使用別名,以便將您的水晶報表所期望的名稱作爲字段的名稱。 –