这是print命令的代码 和成功连接数据库的数据集
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
答案 0 :(得分:1)
MyCommand1.CommandText = "SELECT RTRIM(patient.name) as pName from patient"
然后将pName
字段与水晶报告中的字段匹配,这是Jonathan Willcock所说的。