Yeah, you're right, I forgot to the open method.
I slightly modify my program to instead of supplying the dataset, I would like to manually populate a dataset based on some criteria and make it the reportsource for my existing crystal report. Here is my code:
But when I run this, I got a query engine error. What could be the cause? Where do I have to look into?Code:Dim MyConnection As New SqlConnection() MyConnection.ConnectionString = ConfigurationSettings.AppSettings("VendorConnect") Dim oRpt As rptconsult oRpt = New rptconsult() Try MyConnection.Open() Dim mysql As String Dim grp, dept, from, todate As String grp = "00001" dept = "021" mysql = "select consultfinal.vendorcode, consultfinal.deptname," & _ "consultfinal.purpose, consultfinal.consultdate," & _ "vendormst.vendorname, grpdept.deptdesc, grpdept.deptcode, consultfinal.mercode, grpdept.grpcode from consultfinal, grpdept, vendormst " & _ "where consultfinal.vendorcode = vendormst.vendorcode and " & _ "grpdept.deptcode=consultfinal.deptcode and " & _ "consultfinal.consultdate >=" & obj.PrepareStr(dtpfrom.Value) & " and " & _ "consultfinal.consultdate <=" & obj.PrepareStr(dtpto.Value) & " and " & _ "grpdept.grpcode=" & obj.PrepareStr(grp) & " and consultfinal.deptcode=" & obj.PrepareStr(dept) MessageBox.Show(mysql) Dim mydataadapter As New SqlDataAdapter(mysql, MyConnection) Dim ds As New DataSet() ds.Clear() mydataadapter.Fill(ds) oRpt.SetDataSource(ds) CrystalReportViewer1.ReportSource = oRpt Catch Exp As SqlException MsgBox(Exp.Message, MsgBoxStyle.Critical, "SQL Error") Catch Exp As Exception MsgBox(Exp.Message, MsgBoxStyle.Critical, "General Error") End Try
Thanks a lot.




Reply With Quote