Me.SqlConnection1.ConnectionString = dbconn.ConnectionString
Me.SqlDataAdapter1.SelectCommand.CommandText = "Select * From repSMI where Date Between '" & formSMI.DateTimePicker1.Value & "' and '" & formSMI.DateTimePicker2.Value & "'"
Dim DsetSMI1 As New DataSet
Me.DsetSMI1.Clear()
Me.SqlDataAdapter1.Fill(Me.DsetSMI1, "repSMI")
Dim x As New repSMI
x.SetDataSource(Me.DsetSMI1)
Me.CrystalReportViewer1.ReportSource = x
Me.CrystalReportViewer1.Refresh()
可能的解决办法是什么?谢谢!
答案 0 :(得分:0)
您没有打开连接。而不是将它分配给你的命令。尝试添加
Me.SqlDataAdapter1.SelectCommand.Connection = Me.SqlConnection1
Me.SqlConnection1.Open();
后
Me.SqlConnection1.ConnectionString = dbconn.ConnectionString
填写DataSet后不要忘记关闭它。